spring 整合 mybatis (不含物理分页)
http://www.mybatis.org/spring/mappers.html
http://www.mybatis.org/spring/zh/mappers.html
<?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:tx="http://www.springframework.org/schema/tx"
xmlns:util="http://www.springframework.org/schema/util" 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/util http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.2.xsd"> <util:properties id="db" location="classpath:db.properties"></util:properties>
<context:annotation-config />
<context:component-scan base-package="cn.zno" /> <bean id="dataSourceTest" class="org.apache.commons.dbcp2.BasicDataSource"
destroy-method="close">
<property name="driverClassName" value="#{db['jdbc.driverClassName']}" />
<property name="url" value="#{db['jdbc.url']}" />
<property name="username" value="#{db['jdbc.username']}" />
<property name="password" value="#{db['jdbc.password']}" />
<property name="defaultAutoCommit" value="true" />
</bean> <bean id="txManager"
class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSourceTest" />
</bean> <tx:annotation-driven transaction-manager="txManager" /> <!-- ================= -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSourceTest" />
<property name="configLocation" value="classpath:mybatis-config.xml" />
</bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.zno.dao" />
<property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
</bean> <bean id="aService" class="cn.zno.service.AService"></bean> </beans>
关于 basePackage
第一,支持正则:
如果 value 为 com.lzkj.zsl.clubber.server.entity.*.mapper
会被解析成:classpath*:com/lzkj/zsl/clubber/server/entity/*/mapper/**/*.class
Find all resources that match the given location pattern via the Ant-style PathMatcher. Supports resources in jar files and zip files and in the file system.
org.springframework.core.io.support.PathMatchingResourcePatternResolver.findPathMatchingResources
第二,支持字符串数组:
String CONFIG_LOCATION_DELIMITERS = ",; \t\n";
org.springframework.util.StringUtils.tokenizeToStringArray(this.basePackage, ConfigurableApplicationContext.CONFIG_LOCATION_DELIMITERS)
举例:
value="com.xx,com.yy"
value="com.xx;com.yy;"
value="com.*.mapper"
spring 整合 mybatis (不含物理分页)的更多相关文章
- Spring学习总结(六)——Spring整合MyBatis完整示例
为了梳理前面学习的内容<Spring整合MyBatis(Maven+MySQL)一>与<Spring整合MyBatis(Maven+MySQL)二>,做一个完整的示例完成一个简 ...
- Spring学习总结(五)——Spring整合MyBatis(Maven+MySQL)二
接着上一篇博客<Spring整合MyBatis(Maven+MySQL)一>继续. Spring的开放性和扩张性在J2EE应用领域得到了充分的证明,与其他优秀框架无缝的集成是Spring最 ...
- 分析下为什么spring 整合mybatis后为啥用不上session缓存
因为一直用spring整合了mybatis,所以很少用到mybatis的session缓存. 习惯是本地缓存自己用map写或者引入第三方的本地缓存框架ehcache,Guava 所以提出来纠结下 实验 ...
- 2017年2月16日 分析下为什么spring 整合mybatis后为啥用不上session缓存
因为一直用spring整合了mybatis,所以很少用到mybatis的session缓存. 习惯是本地缓存自己用map写或者引入第三方的本地缓存框架ehcache,Guava 所以提出来纠结下 实验 ...
- spring整合mybatis错误:class path resource [config/spring/springmvc.xml] cannot be opened because it does not exist
spring 整合Mybatis 运行环境:jdk1.7.0_17+tomcat 7 + spring:3.2.0 +mybatis:3.2.7+ eclipse 错误:class path reso ...
- spring 整合Mybatis 《报错集合,总结更新》
错误:java.lang.NoClassDefFoundError: org/aspectj/weaver/reflect/ReflectionWorld$ReflectionWorldExcepti ...
- spring整合mybatis(hibernate)配置
一.Spring整合配置Mybatis spring整合mybatis可以不需要mybatis-config.xml配置文件,直接通过spring配置文件一步到位.一般需要具备如下几个基本配置. 1. ...
- spring 整合 mybatis 中数据源的几种配置方式
因为spring 整合mybatis的过程中, 有好几种整合方式,尤其是数据源那块,经常看到不一样的配置方式,总感觉有点乱,所以今天有空总结下. 一.采用org.mybatis.spring.mapp ...
- Mybatis学习(六)————— Spring整合mybatis
一.Spring整合mybatis思路 非常简单,这里先回顾一下mybatis最基础的根基, mybatis,有两个配置文件 全局配置文件SqlMapConfig.xml(配置数据源,全局变量,加载映 ...
- Spring整合MyBatis 你get了吗?
Spring整合MyBatis 1.整体架构dao,entity,service,servlet,xml 2..引入依赖 <dependencies> <dependency> ...
随机推荐
- PHp引用,函数引用,对象引用(初学者必看)
转自:http://blog.sina.com.cn/s/blog_948254830100vs2e.html 收集整理: 第 二 教 育 资 源 网 在PHP 中引用的意思是:不同的名字访问同一个变 ...
- c#中如何获取本机用户名、MAC地址、IP地址、硬盘ID、CPU序列号、系统名称、物理内存
我们在利用C#开发桌面程序(Winform)程序的时候, 经常需要获取一些跟系统相关的信息, 以下这些代码获取能有些用处. c#中如何获取本机用户名.MAC地址.IP地址.硬盘ID.CPU序列号.系统 ...
- 转载----我与CMDB不得不说的故事
每次读到配置管理相关的书籍时,我总在想:“这些定义很精准,流程也很完整,但这不是真正的难题.”对于一个配置管理者来说,真正的难题不是绘制“庞大而精美”的数据模型,不是设计“全天候.无死角”的管控流程, ...
- c++builder自定义控件
c++builder自定义控件 http://docwiki.embarcadero.com/CodeExamples/XE8/en/RegisterComponents_%28C%2B%2B%29 ...
- Bootstrap 与 Jquery validate 结合使用——多个规则实现
进行开发的时候,遇到了需要有多个规则来校验,如新用户过来一套校验规则,老用户过来又是一套规则,这时候就要需要定义多套校验规则. 首先要熟悉Bootstrap和Jquery validate的使用,详情 ...
- UNITY UI字体模糊的原因
根本原因:像素少. 解决办法:字体的 font size将像素设置大些,然后用scale来缩放大小
- MyBatis3 用log4j在控制台输出 SQL
用log4j在控制台输出 SQL 在spring-mybatis.xml中配置 <bean id="sqlSessionFactory" class="org.my ...
- Linux下Spark框架配置(Python)
简述 Spark是UC Berkeley AMP lab所开源的类Hadoop MapReduce的通用并行框架,Spark,拥有Hadoop MapReduce所具有的优点:但不同于MapRedu ...
- 【BZOJ3926】诸神眷顾的幻想乡 【广义后缀自动机】
题意 给定一棵树,每个结点有一个颜色,问树上有多少种子串(定义子串为两点上路径颜色的序列).保证叶子结点<=20 分析 我们可以发现一个结论,任意一个子串一定是以某个叶子结点为根的trie的后缀 ...
- 26-三个水杯(bfs)
三个水杯 时间限制:1000 ms | 内存限制:65535 KB 难度:4 描述 给出三个水杯,大小不一,并且只有最大的水杯的水是装满的,其余两个为空杯子.三个水杯之间相互倒水,并且水杯没有 ...