SSM框架整合的其它方式
---------------------siwuxie095
SSM 框架整合的其它方式
1、主要是整合
Spring 框架和 MyBatis 框架时,可以不写
MyBatis 核心配置文件:mybatis-config.xml
2、把
MyBatis 核心配置文件中的配置全都转移到
Spring
核心配置文件中
3、具体实现
applicationContext.xml:
|
<?xml <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:context="http://www.springframework.org/schema/context" xmlns:tx="http://www.springframework.org/schema/tx" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.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 http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- 使用spring自带的占位符替换功能 --> <bean
<!-- 允许JVM参数覆盖 --> <property
<!-- 忽略没有找到的资源文件 --> <property
<!-- 配置资源文件(也称 <property <list> <value>classpath:jdbc.properties</value> </list> </property>
</bean>
<!-- 配置 BoneCP 连接池 --> <bean
<!-- 数据库驱动 --> <property
<!-- 相应驱动的jdbcUrl --> <property
<!-- 数据库的用户名 --> <property
<!-- 数据库的密码 --> <property
,如果要取消则设置为0 --> <property
,如果要永远存活设置为0 --> <property
<!-- 每个分区最大的连接数 --> <property
<!-- 每个分区最小的连接数 --> <property
</bean>
<!-- 将 SqlSessionFactory 对象的创建交给 Spring 进行管理 --> <bean
<!-- 指定数据源 --> <property
<!-- 开启自动驼峰命名规则映射 --> <property <bean <property </bean> </property>
<!-- 指定 MyBatis 映射配置文件的位置(路径) --> <property <!-- 指定 <property
</bean>
<!-- 配置 Service 对象 --> <bean <property </bean>
<!-- 配置映射器接口(Mapper 接口)的扫描包 --> <bean <!-- 如有多个包,以逗号 <property </bean>
<!-- 配置映射器接口(以下方法二选一即可,这里选择法二):
法一:逐个配置:配置映射器接口(Mapper 接口)的对象
<bean id="userMapper" class="org.mybatis.spring.mapper.MapperFactoryBean"> <property name="mapperInterface" value="com.siwuxie095.mapper.UserMapper"/> <property name="sqlSessionFactory" ref="sqlSessionFactory"/> </bean>
法二:统一配置:配置映射器接口(Mapper 接口)的扫描包
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="com.siwuxie095.mapper"/> </bean>
-->
<!-- 配置事务管理器 --> <bean class="org.springframework.jdbc.datasource.DataSourceTransactionManager"> <!-- 注入 dataSource --> <property </bean> <!-- 配置事务注解,即 <tx:annotation-driven
<!-- 一般事务管理都是在 Service 层进行,只需在 Service 类上加上 @Transactional 注解 --> </beans> |
注:主要针对
sqlSessionFactory
的
Bean 做修改
【made by siwuxie095】
SSM框架整合的其它方式的更多相关文章
- SSM框架整合项目 :租房管理系统
使用ssm框架整合,oracle数据库 框架: Spring SpringMVC MyBatis 导包: 1, spring 2, MyBatis 3, mybatis-spring 4, fastj ...
- SSM框架整合环境构建——基于Spring4和Mybatis3
目录 环境 配置说明 所需jar包 配置db.properties 配置log4j.properties 配置spring.xml 配置mybatis-spring.xml 配置springmvc.x ...
- springmvc(二) ssm框架整合的各种配置
ssm:springmvc.spring.mybatis这三个框架的整合,有耐心一步步走. --WH 一.SSM框架整合 1.1.整合思路 从底层整合起,也就是先整合mybatis与spring,然后 ...
- SSM框架整合过程总结
-----------------------siwuxie095 SSM 框架整合过程总结 1.导入相关 jar 包( ...
- 使用IntelliJ IDEA创建Maven聚合工程、创建resources文件夹、ssm框架整合、项目运行一体化
一.创建一个空的项目作为存放整个项目的路径 1.选择 File——>new——>Project ——>Empty Project 2.WorkspaceforTest为项目存放文件夹 ...
- SSM框架整合(实现从数据库到页面展示)
SSM框架整合(实现从数据库到页面展示) 首先创建一个spring-web项目,然后需要配置环境dtd文件的引入,环境配置,jar包引入. 首先让我来看一下ssm的基本项目配件.(代码实现) 1.首先 ...
- JAVAEE——宜立方商城01:电商行业的背景、商城系统架构、后台工程搭建、SSM框架整合
1. 学习计划 第一天: 1.电商行业的背景. 2.宜立方商城的系统架构 a) 功能介绍 b) 架构讲解 3.工程搭建-后台工程 a) 使用maven搭建工程 b) 使用maven的tomcat插件启 ...
- SpringMVC札集(10)——SSM框架整合
自定义View系列教程00–推翻自己和过往,重学自定义View 自定义View系列教程01–常用工具介绍 自定义View系列教程02–onMeasure源码详尽分析 自定义View系列教程03–onL ...
- (转)淘淘商城系列——SSM框架整合之Dao层整合
http://blog.csdn.net/yerenyuan_pku/article/details/72721093 一个项目中往往有三层即Dao层.Service层和Web层,看标题就知道了,本文 ...
随机推荐
- JDK下载与安装、 Eclipse下载与使用、 Tomcat下载与使用、 MySQL安装与使用
前言 本文将介绍JDK的下载与安装,eclipse的下载与使用,Tomcat的下载与使用,MySQL的安装与使用. JDK下载与安装 一.JRE与JDK介绍 java是当前比较流行的一种编程语言,当我 ...
- django jquery ajax 知识点
示例: 1 2 3 4 5 6 7 8 9 10 11 12 13 14 <div id='d'>1</div> <div> <div id='i1' nam ...
- CVE-2017-12615和CVE-2017-12616
Tomcat代码执行漏洞分析测试 1. 漏洞花絮 2017年9月19日,Apache Tomcat官方确认并修复了两个高危漏洞,漏洞CVE编号:CVE-2017-12615和CVE-20 ...
- POJ3017 Cut the Sequence
题意 Language:Default Cut the Sequence Time Limit: 2000MS Memory Limit: 131072K Total Submissions: 122 ...
- openstry lua redis实现负载均衡
需求: 通过URI地址http://10.0.0.148/test2?uuid=123的uuid参数值的第一位,去实现redis的负载均衡 若uuid第一位为1,那么去10.0.0.148的redis ...
- Spring Cloud(Dalston.SR5)--Zuul 网关-过滤器
Spring Cloud 为 HTTP 请求的各个阶段提供了多个过滤器,这些过滤器的执行顺序由各自提供的一个 int 值决定,提供的值越小则优先级越高,默认的过滤器及优先级如下: 自定义过滤器 在默认 ...
- Excel技巧--单列变多行
当上图的单列转变成多行时,可以这么做: 1.在第一行输入A2.A3,向右拖拉第一行: 2.第二行按第一行最右顺序,写下A12,再向右拖拉出第二行: 3.选择这两行,再拖拉出一串连续顺序的多行来: 4. ...
- 在高并发情况nginx的作用
1 场景一:如图 在单机的情况下例如:单个tomcat 有100w条请求的时候,而默认tomcat支持的并发数量并不能达到要求,所所以单台服务器 扛不住 容易宕机,瘫痪 2 高并发的情况下要让服务器不 ...
- The 'INFORMATION_SCHEMA.GLOBAL_STATUS' feature is disabled; see the documentation for 'show_compatibility_56'
--从mysql5.7.6开始information_schema.global_status已经开始被舍弃,为了兼容性,此时需要打开 show_compatibility_56 mysql> ...
- python:id与小数据池与编码
一.id与小数据池 id:查的是内存地址 a = 100 b = 100 print(a == b)#比较的数值 print(a is b)#比较的是id print(id(a),id(b))#id相 ...