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> ...
随机推荐
- line 3: /usr/local/arm/4.3.2/bin/arm-none-linux-gnueabi-gcc: No such file or directory
sudo apt-get install lib32ncurses5(网上下载的很多arm-linux-gcc都是32位的,64位的ubuntu需要按此包)
- node的超时timeout
如果在指定的时间内服务器没有做出响应(可能是网络间连接出现问题,也可能是因为服务器故障或网络防火墙阻止了客户端与服务器的连接),则响应超时,同时触发http.ServerResponse对象的time ...
- 【BZOJ】2657: [Zjoi2012]旅游(journey)(树的直径)
题目 传送门:QWQ 分析 在任意两个不相邻的点连一条线,求这条线能穿过几个三角形. 建图比较讲究(详见代码) 求树的直径. 代码 #include <bits/stdc++.h> usi ...
- 用 Sqlmap 识别 WAF
命令: ┌─[root@sch01ar]─[~] └──╼ #sqlmap -u "http://www.sch01ar.com/" --identify-waf --batch ...
- 使用java获取自己的机器网卡
package org.ibase4j.core.util; import java.io.BufferedReader;import java.io.IOException;import java. ...
- [OpenCV Qt教程] 如何在内存中压缩图像
本文译自:http://www.robot-home.it/blog/en/software/tutorial-opencv-qt-comprimere-un-immagine-in-memoria/ ...
- HTTP与TCP/IP的区别
TPC/IP协议是传输层协议,主要解决数据如何在网络中传输,而HTTP是应用层协议,主要解决如何包装数据.关于TCP/IP和HTTP协议的关系,网络有一段比较容易理解的介绍:“我们在传输数据时,可以只 ...
- leetcode674
public class Solution { public int FindLengthOfLCIS(int[] nums) { var len = nums.Length; ) { return ...
- leetcode357
public class Solution { public int CountNumbersWithUniqueDigits(int n) { ) { ; } ; ; ; && av ...
- c++Builder Delphi XML 解析例子
XMLDocument; Xml.XMLIntf.hpp Xml.XMLDoc.hpp #include "Xml.Win.msxmldom.hpp" XMLDocument控件 ...