spring-mybatis.xml 4.22 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">
	<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
		<property name="mapperLocations">
			<list>
				<value>classpath*:mybatis/xml/**/*Mapper.xml</value>
				<value>classpath*:mybatis/mysql/SiteMapper.xml</value>
				<value>classpath*:mybatis/mysql/Excel_columnMapper.xml</value>
				<value>classpath*:mybatis/mysql/VariableMapper.xml</value>
				<value>classpath*:mybatis/mysql/VarItemMapper.xml</value>
				<value>classpath*:mybatis/mysql/SystemTemplateMapper.xml</value>
				<value>classpath*:mybatis/mysql/MsgChannelMapper.xml</value>
			</list>
		</property>
		<property name="dataSource" ref="dataSource" />
		<property name="plugins">
			<bean class="cn.runsa.crmapp.common.page.PageInterceptor">
				<property name="databaseType" value="mysql" />
			</bean>
		</property>
	</bean>

	<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
		<property name="basePackage" value="cn.runsa.portal.base.dao,cn.runsa.crmapp.customer.mapper,cn.runsa.crmapp.common.mapper,cn.runsa.crmapp.points.mapper,cn.runsa.crmapp.order.mapper,cn.runsa.crmapp.coupon.mapper,cn.runsa.crmapp.goods.mapper" />
		<property name="nameGenerator" ref="qualifiedBeanNameGenerator"/>
	</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" mode="proxy"/>

	<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
		<property name="url" value="${dataSource.url}" />
		<property name="username" value="${dataSource.username}" />
		<property name="password" value="${dataSource.password}" />

		<!-- 配置初始化大小、最小、最大 -->
		<property name="initialSize" value="${dataSource.initialSize}" />
		<property name="minIdle" value="${dataSource.minIdle}" />
		<property name="maxActive" value="${dataSource.maxActive}" />

		<!-- 配置获取连接等待超时的时间 -->
		<property name="maxWait" value="${dataSource.maxWait}" />

		<!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
		<property name="timeBetweenEvictionRunsMillis" value="${dataSource.timeBetweenEvictionRunsMillis}" />

		<!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
		<property name="minEvictableIdleTimeMillis" value="${dataSource.minEvictableIdleTimeMillis}" />

		<property name="validationQuery" value="${dataSource.validationQuery}" />
		<property name="testWhileIdle" value="${dataSource.testWhileIdle}" />
		<property name="testOnBorrow" value="${dataSource.testOnBorrow}" />
		<property name="testOnReturn" value="${dataSource.testOnReturn}" />

		<!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
		<property name="poolPreparedStatements" value="${dataSource.poolPreparedStatements}" />
		<!-- 配置监控统计拦截的filters -->
		<property name="filters" value="${dataSource.filters}" />
		<property name="maxPoolPreparedStatementPerConnectionSize" value="${dataSource.maxPoolPreparedStatementPerConnectionSize}"/>
	</bean>
</beans>