spring-mybatis.xml 2.67 KB
<?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:context="http://www.springframework.org/schema/context"
	xmlns:tx="http://www.springframework.org/schema/tx" xmlns:aop="http://www.springframework.org/schema/aop"
	xmlns:jdbc="http://www.springframework.org/schema/jdbc" xmlns:jpa="http://www.springframework.org/schema/data/jpa"
	xsi:schemaLocation="http://www.springframework.org/schema/beans 
           	http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
           	http://www.springframework.org/schema/context
           	http://www.springframework.org/schema/context/spring-context-4.0.xsd
           	http://www.springframework.org/schema/tx
      		http://www.springframework.org/schema/tx/spring-tx-4.0.xsd
           	http://www.springframework.org/schema/aop
           	http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
			http://www.springframework.org/schema/jdbc
			http://www.springframework.org/schema/jdbc/spring-jdbc-4.0.xsd" default-lazy-init="true">

	<!-- 拦截DAO执行记录和日间
	<bean id="druid-stat-interceptor"
		class="com.alibaba.druid.support.spring.stat.DruidStatInterceptor"></bean> 
	<bean id="druid-stat-pointcut" class="org.springframework.aop.support.JdkRegexpMethodPointcut"
		scope="prototype">
		<property name="patterns">
			<list>
				<value>cn.runsa.portal.web.dao.*</value>
			</list>
		</property>
	</bean>
	<aop:config>
		<aop:advisor advice-ref="druid-stat-interceptor"
			pointcut-ref="druid-stat-pointcut" />
	</aop:config>
	 -->

	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="typeAliasesPackage" value="cn.runsa.portal.base.entity" />
		<property name="mapperLocations" value="classpath*:mybatis/mysql/**/*Mapper.xml" />
		<property name="dataSource" ref="dataSource" />
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="cn.runsa.portal.base.dao" />
	</bean>

	<bean name="transactionManager"
		class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
		<property name="dataSource" ref="dataSource" />
	</bean>

	<tx:annotation-driven transaction-manager="transactionManager"
		proxy-target-class="true" />

	<beans profile="develop">
		<context:property-override location="classpath:datasource-develop.properties" />
		<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"></bean>
	</beans>

	<beans profile="product">
		<context:property-override location="classpath:datasource-product.properties" />
		<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource"></bean>
	</beans>
</beans>