<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
	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-4.1.xsd">

	<!-- 定义Mybatis的SqlSessionFactory -->
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<!-- 定义数据源 -->
		<property name="dataSource" ref="${dataSource}"/>
		<property name="databaseIdProvider" ref="databaseIdProvider"/>
		<!-- 指定mybatis全局配置文件 -->
		<property name="configLocation" value="classpath:mybatis/mybatis-config.xml" />
		<!-- 扫描mappers目录以及子目录下的所有xml文件 -->
		<property name="mapperLocations" value="classpath:mybatis/mappers/**/*.xml" />
		<!-- 别名扫描包 -->
		<property name="typeAliasesPackage" value="com.njcn.pojo com.pqs9000.pojo com.njcn.sso.pojo" />
	</bean>

	<bean id="transactionManagerManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="${dataSource}"/>
	</bean>

	<!-- 定义Mapper接口扫描器 -->
	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.njcn.mapper com.pqs9000.mapper" />
	</bean>

	<!--配置通用mapper -->
	<bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="com.njcn.mapper com.pqs9000.mapper" />
		<property name="properties">
			<value>
				mappers=tk.mybatis.mapper.common.Mapper
				<!-- 仅对insert有效 -->
				ORDER=BEFORE
			</value>
		</property>
	</bean>

</beans>
