spring-mybatis.xml
4.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
<?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,cn.runsa.portal.query.entity,cn.runsa.crmapp.customer.entity,cn.runsa.crmapp.points.entity,cn.runsa.crmapp.coupon.entity" />
-->
<property name="mapperLocations" >
<list>
<value>classpath*:mybatis/xml/**/*Mapper.xml</value>
<value>classpath*:mybatis/mysql/**/*Mapper.xml</value>
</list>
</property>
<property name="dataSource" ref="dataSource" />
</bean>
<bean id="qualifiedBeanNameGenerator" class="cn.runsa.portal.base.QualifiedBeanNameGenerator"></bean>
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="cn.runsa.portal.base.dao,cn.runsa.portal.query.dao,cn.runsa.crmapp.customer.mapper,cn.runsa.crmapp.common.mapper,cn.runsa.crmapp.points.mapper,cn.runsa.crmapp.coupon.mapper,cn.runsa.crmapp.order.mapper,cn.runsa.crmapp.market.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" />
<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>