建立一个WEB工程
1.加入spring
①.加入jar包
②.在src路径下新建一个源文件Source Folder,加入一个spring的applicationContext.xml配置文件
③.在web.xml文件中配置IOC容器的初始化
2.加入hibernate
①.加入jar包
②.在源文件下加入一个hibernate.cfg.xml配置文件
I.配置相关属性:方言,SQL的显示与格式化,二级缓存相关
③.建立entity包
I.创建持久化类
II.创建其对应的.hbm.xml映射文件
④.整合spring
I.加入c3p0数据源,和对应的Oracle数据库驱动jar包
II.在spring的配置文件applicationContext.xml中配置
<1>.配置数据源dataSource的bean
1) 源文件下新建db.propertise,并配置相关属性
2) 导入db.propertise文件
<2>.配置sessionFactory的bean
1) dataSource
2) configLocation value=classpath:hibernate.cfg.xml
3) mappingLocationsvalue=classpath:com/hx/ssh/entity/*.hbm.xml
<3>.配置声明式事务
1) 事务管理器 transactionManager
2) 事务 txAdvice
3) 切点 pointcut expression="execution(* com.hx.ssh.service.*.*(..))" txPointcut
4).关联事务和切点
3.加入struts
①.加入jar包
②.在web.xml中复制粘贴struts的核心过滤器
③.在源文件下加入struts.xml配置文件
④.整合spring
I.加入整合spring的struts的jar包
II.在applicationContext.xml配置文件中配置Action的bean
<1>.注意添加属性Scope为prototype,否则默认为单例
III.在struts.xml中配置Action
<1>.注意class属性不再是全类名,class="bean的名称"
1.加入spring
①.加入jar包
②.在src路径下新建一个源文件Source Folder,加入一个spring的applicationContext.xml配置文件
③.在web.xml文件中配置IOC容器的初始化
2.加入hibernate
①.加入jar包
②.在源文件下加入一个hibernate.cfg.xml配置文件
I.配置相关属性:方言,SQL的显示与格式化,二级缓存相关
③.建立entity包
I.创建持久化类
II.创建其对应的.hbm.xml映射文件
④.整合spring
I.加入c3p0数据源,和对应的Oracle数据库驱动jar包
II.在spring的配置文件applicationContext.xml中配置
<1>.配置数据源dataSource的bean
1) 源文件下新建db.propertise,并配置相关属性
2) 导入db.propertise文件
<2>.配置sessionFactory的bean
1) dataSource
2) configLocation value=classpath:hibernate.cfg.xml
3) mappingLocationsvalue=classpath:com/hx/ssh/entity/*.hbm.xml
<3>.配置声明式事务
1) 事务管理器 transactionManager
2) 事务 txAdvice
3) 切点 pointcut expression="execution(* com.hx.ssh.service.*.*(..))" txPointcut
4).关联事务和切点
3.加入struts
①.加入jar包
②.在web.xml中复制粘贴struts的核心过滤器
③.在源文件下加入struts.xml配置文件
④.整合spring
I.加入整合spring的struts的jar包
II.在applicationContext.xml配置文件中配置Action的bean
<1>.注意添加属性Scope为prototype,否则默认为单例
III.在struts.xml中配置Action
<1>.注意class属性不再是全类名,class="bean的名称"
整合完成