标签:文件 bean property ext session class dex ram map
resources
spring
applicationContext.xml
sqlmap
mapper
aaamapper.xml
bbbmapper.xml
mybatis-config.xml
<dependency> <groupId>org.ibatis</groupId> <artifactId>ibatis</artifactId> <version>2.3.3.720</version> </dependency>
<dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis</artifactId> <version>3.4.1</version> </dependency> <dependency> <groupId>org.mybatis</groupId> <artifactId>mybatis-spring</artifactId> <version>1.3.0</version> </dependency>
<bean id="xxsqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean"> <property name="dataSource" ref="dataSource_agencyjizhong"/> <property name="mapperLocations" value="classpath:sqlmap/mapper/*.xml"/> <property name="configLocation" value="classpath:sqlmap/mybatis-config.xml"/> </bean>
如果id为默认的sqlSessionFactory,会导致MapperScannerConfigurer在加载bean时,加载PropertyPlaceholderConfigurer还没来得及替换定义中的变量,其中就包含数据源中的配置(例如:${env})
<bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate"> <constructor-arg index="0" ref="xxsqlSessionFactory"/> </bean> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <!--映射器接口文件的包路径--> <property name="basePackage" value="com.maosheng.mapper"/> <property name="sqlSessionFactoryBeanName" value="xxsqlSessionFactory"/> </bean>
<configuration> <settings></settings> <typeAliases></typeAliases> <mappers></mappers> </configuration>
<!DOCTYPE configuration PUBLIC "-//mybatis.org//DTD Config 3.0//EN" "http://mybatis.org/dtd/mybatis-3-config.dtd">
<settings x="y" foo="bar"/>
<settings> <setting name="x" value="y"/> <setting name="foo" value="bar"/> </settings>
将每个***mapper.xml中下的typeAlias全部移至sqlMapConfig.xml中下
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
注意和${value}的区别
标签:文件 bean property ext session class dex ram map
原文地址:http://www.cnblogs.com/studyhs/p/6290531.html