SSH三大框架简单整合
来源:互联网 发布:软件单元测试报告 rup 编辑:程序博客网 时间:2024/05/18 20:09
SSH整合:我写的整合方式是xml配合注解的整合方式,按程序流程整合。
(一)导入jar包:导入SSH整合的基本jar包
(二)服务器启动:加载web.xml
在web.xml中配置Struts2的核心入口(核心过滤器)
配置 Spring创建ApplicationContext的监听器 ContextLoaderListener位于spring-web的jar包中
配置全局参数,监听器获取applicationContext.xml的路径,为了让ApplicationContext对象加载spring配置文件。
(三)配置applicationContext.xml:导入spring配置文件的约束 引入hibernate配置信息
1、导入约束
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd">
</beans>
2、开启包扫描器和事务对注解的支持
3、配置数据源(连接池)我这里配置的c3p0连接池
4、配置hibernate配置信息:hibernate和spring的整合就是将sessionFactory的创建权交给spring 由spring管理sessionFactory 这里利用spring框架的hiernate模板中的一个LocalSessionFactoryBean类,对sessionFactory进行封装。(具体的一些封装细节和session封装细节,以后我会慢慢写出来)
一个要注意的问题:导包要一致,因为hibernate在spring中有3,4,5三个包
hibernate配置信息:
5、开启事务管理器
6、实例化hibernateTemplate(连接session,在dao层需要用它进行数据库操作)
(四) 将各层纳入spring管理,并持久化类
dao:
service:
action:
大致ssh框架就整合完毕,一些简单的流程分享给大家。
- SSH三大框架简单整合
- SSH三大框架整合
- SSH 三大框架整合
- java web ssh三大框架整合简单入门
- ssh三大框架整合-整合实例
- ssh三大框架的整合
- 【insigma】SSH三大框架整合步骤
- SSH三大框架整合全程记录
- ssh三大框架整合 getHibernateTemplate
- ssh三大框架整合的配置
- 三大框架整合ssh(前言)
- SSH之三大框架的整合
- SSH三大框架整合步骤
- SSH之三大框架整合配置文件
- SSH三大框架整合原理
- SSH三大框架整合步骤
- SSH三大框架注解整合
- ssh三大框架整合--jar包
- 产品——小理解,
- Duplicate entry 'XXX' for key 'XXX'
- C# 获取路径中,文件名、目录、扩展名等
- 机器学习之-线性回归算法【人工智能工程师--AI转型必修课】
- SQL数据库50例题
- SSH三大框架简单整合
- 方兴东黑阿里吃京东,独立第三方沦为笑柄
- 三大框架 SSM 搭建基础项目 Maven
- 文件描述符
- SQL建表字段语法DEFAULT和字段 NULL的组合定义表现
- python——pandas的pivot_table使用
- 安卓开发中的排序
- POI解析单元格格式
- Universal 2nd Factor (U2F) 概述(5)-用户提醒:设备“激活”和浏览器提示