spring 整合 struts2 + Hibernate application配置文件(基于注解)
下面是 application.xml 文件。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
">
<!-- 上面的开启了
aop命名空间
tx命名空间
context命名空间
--> <!-- 开启注解开发spring模式 -->
<context:component-scan base-package="cn.itcast"/> <!-- hibernateTemplate,用于提供dao层的各种操作 -->
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate">
<!--
注入SessionFactory,虽然HibernateTemplate类中没有对应的sessionFactory属性,
但是其父类HibernateAccessor有
-->
<property name="sessionFactory" ref="sessionFactory"/>
</bean> <!--
sessionFactory的bean,这里使用的sessionFactory不再是SessionFactoryBean了,
而是它的子类AnnotationSessionFactoryBean,专门用于注解的sessionFactorybean
-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean">
<!-- 注入dataSource数据源 -->
<property name="dataSource" ref="dataSource"/>
<!-- 注入Hibernate的各种属性 -->
<property name="hibernateProperties">
<props>
<!-- 数据库方言的设置,必须设置,用于生成正确的sql语句 -->
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop><!-- 展示sql,非必须,开发使用 -->
<prop key="hibernate.format_sql">true</prop><!-- 格式化sql,非必须,开发使用 -->
</props>
</property>
<!--
资源注册,和之前的不一样了,因为采用了注解模式,没有了xxxhbm.xml文件了,不能像之前那样注册了。
采用的是包扫描
-->
<property name="packagesToScan">
<list>
<!-- 这里使用的package,不是路径,所以使用的是点,而不是斜杠 -->
<value>cn.itcast.ssh.annotation.user.vo</value>
</list>
</property>
</bean> <!-- dataSource,配置数据源,包括驱动,url,用户名,密码 -->
<bean id="dataSource" class="org.springframework.jdbc.datasource.DriverManagerDataSource">
<property name="driverClassName" value="com.mysql.jdbc.Driver"/>
<property name="url" value="jdbc:mysql://localhost:3306/DB_Demo1"/>
<property name="username" value="root"/>
<property name="password" value="root"/>
</bean>
</beans>
spring 整合 struts2 + Hibernate application配置文件(基于注解)的更多相关文章
- Spring整合Struts2,Hibernate的xml方式
		作为一个学习中的码农,一直学习才是我们的常态,所以最近学习了SSH(Spring,Struts2,Hibernate)整合,数据库用的MySQL. 写了一个简单的例子,用的工具是IntelliJ Id ... 
- spring整合struts2,hibernate
		1.导包 struts2包(不需要导入,之前学习struts2时已经导入) hibernate包(不需要导入,之前学习hibernate时已经导入) Spring包 整合hibernate的没有hib ... 
- 一 SSH整合:Spring整合Struts2的两种方式,struts.xml管理Action&Bean管理Action
		SSH回顾 1 引入jar包 Struts2的jar包 D:\Struts2\struts-2.3.35\apps\struts2-blank\WEB-INF\lib 开发基本包 Struts2有一 ... 
- spring整合mybatis(hibernate)配置
		一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ... 
- Struts2的使用以及Spring整合Struts2
		一.如何单独使用Struts2 (1)引入struts2的jar包 commons-fileupload-1.2.1.jar freemarker-2.3.15.jar ognl-2.7.3.jar ... 
- Spring声明式事务管理(基于注解方式实现)
		----------------------siwuxie095 Spring 声明式事务管理(基于注解方式实现) 以转 ... 
- Spring整合Struts2框架的第二种方式(Action由Spring框架来创建)(推荐大家来使用的)
		1. spring整合struts的基本操作见我的博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2框架整 ... 
- Spring整合Struts2框架的第一种方式(Action由Struts2框架来创建)。在我的上一篇博文中介绍的通过web工厂的方式获取servcie的方法因为太麻烦,所以开发的时候不会使用。
		1. spring整合struts的基本操作见我的上一篇博文:https://www.cnblogs.com/wyhluckdog/p/10140588.html,这里面将spring与struts2 ... 
- Spring框架学习(5)spring整合struts2
		内容源自:spring整合struts2 一.spring框架对struts等表现层框架的整合原理 : 使用spring的ioc容器管理struts中用于处理请求的Action 将Action配置成i ... 
随机推荐
- angular5学习笔记  路由通信
			首先在路由字典中,接收值的组件中加上:/:id 在发送值的组件中,发送值的方式有几种. 第一种:<a routerLink="/detail/1">新闻详情1</ ... 
- 20155203 2016-2017-2 《Java程序设计》第10周学习总结
			20155203 2016-2017-2 <Java程序设计>第10周学习总结 教材学习内容总结 网络编程(Java Socket编程) Java最初是作为网络编程语言出现的,其对网络提供 ... 
- 20155229 实验一《Java开发环境的熟悉》实验报告
			20155229 实验一<Java开发环境的熟悉>实验报告 实验内容 1.使用JDK编译.运行简单的Java程序: 2.使用Idea 编辑.编译.运行.调试Java程序. 实验步骤 (一) ... 
- 20155338 《Java程序设计》实验一(Java开发环境的熟悉)实验报告
			20155338 <Java程序设计>实验一(Java开发环境的熟悉)实验报告 一.实验内容及步骤 1.用JDK编译.运行简单的java程序 步骤一(新建文件夹): 打开windows下的 ... 
- echarts x轴文字换行显示
			xAxis : [ { splitLine:{show:false}, type : 'category', data : ['社交人际','沟通交流','心理认知','游戏玩耍','大小运动','生 ... 
- 【LG3206】[HNOI2010]城市建设
			[LG3206][HNOI2010]城市建设 题面 洛谷 题解 有一种又好想.码得又舒服的做法叫线段树分治+\(LCT\) 但是因为常数过大,无法跑过此题. 所以这里主要介绍另外一种玄学\(cdq\) ... 
- 【JUC源码解析】PriorityBlockingQueue
			简介 基于数据结构堆实现的线程安全的无界队列,这个堆的内存结构是数组,结合了数组和二叉树的特点. 堆 以下内容参考<编程珠玑>和<算法导论>有关堆的章节. 数据结构 堆是用来表 ... 
- 【Jmeter测试】如何使用CSV Data Set Config获取参数
			Jmeter提供CSV Data Set Config作为参数获取的一种方式  1.文件名:csv文件的绝对路径2.文件编码:根据运行环境设置,个人常用的是mac和linux,所以这里选择UT ... 
- 08-base镜像
			base 镜像有两层含义: 不依赖其他镜像,从 scratch 构建. 其他镜像可以之为基础进行扩展. 所以,能称作 base 镜像的通常都是各种 Linux 发行版的 Docker 镜像,比如 Ub ... 
- 423. Valid Parentheses【LintCode  java】
			Description Given a string containing just the characters '(', ')', '{', '}', '[' and ']', determine ... 
