1
|
-<?xml version="1.0" encoding="UTF-8"?>
|
|
|
2
|
-<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context"
|
|
|
3
|
- xmlns:mvc="http://www.springframework.org/schema/mvc" xmlns:aop="http://www.springframework.org/schema/aop"
|
|
|
4
|
- xsi:schemaLocation="http://www.springframework.org/schema/beans
|
|
|
5
|
- http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
|
|
6
|
- http://www.springframework.org/schema/context
|
|
|
7
|
- http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
|
|
8
|
- http://www.springframework.org/schema/mvc
|
|
|
9
|
- http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
|
|
10
|
- http://www.springframework.org/schema/aop
|
|
|
11
|
- http://www.springframework.org/schema/aop/spring-aop-3.1.xsd">
|
|
|
12
|
-
|
|
|
13
|
- <!-- yoho_passport 数据源 -->
|
|
|
14
|
- <bean id="yohobuylogsMasterDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
|
15
|
- <property name="driverClassName" value="${jdbc.mysql.driver}" />
|
|
|
16
|
- <property name="url" value="${jdbc.mysql.yohopassport.master.url}" />
|
|
|
17
|
- <property name="username" value="${jdbc.mysql.yohopassport.username}" />
|
|
|
18
|
- <property name="password" value="${jdbc.mysql.yohopassport.password}" />
|
|
|
19
|
- <!-- 初始化连接大小 -->
|
|
|
20
|
- <property name="initialSize" value="${jdbc.mysql.initialSize}"></property>
|
|
|
21
|
- <!-- 连接池最大数量 -->
|
|
|
22
|
- <property name="maxActive" value="${jdbc.mysql.maxActive}"></property>
|
|
|
23
|
- <!-- 连接池最大空闲 -->
|
|
|
24
|
- <property name="maxIdle" value="${jdbc.mysql.maxIdle}"></property>
|
|
|
25
|
- <!-- 连接池最小空闲 -->
|
|
|
26
|
- <property name="minIdle" value="${jdbc.mysql.minIdle}"></property>
|
|
|
27
|
- <!-- 获取连接最大等待时间 -->
|
|
|
28
|
- <property name="maxWait" value="${jdbc.mysql.maxWait}"></property>
|
|
|
29
|
- <!--定时对线程池中的链接进行校验 -->
|
|
|
30
|
- <property name="testWhileIdle" value="${jdbc.mysql.testWhileIdle}"></property>
|
|
|
31
|
- <property name="timeBetweenEvictionRunsMillis" value="${jdbc.mysql.timeBetweenEvictionRunsMillis}"></property>
|
|
|
32
|
- <property name="validationQuery" value="${jdbc.mysql.validationQuery}"></property>
|
|
|
33
|
- <property name="testOnBorrow" value="${jdbc.mysql.testOnBorrow}"></property>
|
|
|
34
|
- <property name="testOnReturn" value="${jdbc.mysql.testOnReturn}"></property>
|
|
|
35
|
-
|
|
|
36
|
- </bean>
|
|
|
37
|
- <bean id="yohobuylogsSlaveDataSource" class="org.apache.commons.dbcp.BasicDataSource" destroy-method="close">
|
|
|
38
|
- <property name="driverClassName" value="${jdbc.mysql.driver}" />
|
|
|
39
|
- <property name="url" value="${jdbc.mysql.yohopassport.slave.url}" />
|
|
|
40
|
- <property name="username" value="${jdbc.mysql.yohopassport.username}" />
|
|
|
41
|
- <property name="password" value="${jdbc.mysql.yohopassport.password}" />
|
|
|
42
|
- <!-- 初始化连接大小 -->
|
|
|
43
|
- <property name="initialSize" value="${jdbc.mysql.initialSize}"></property>
|
|
|
44
|
- <!-- 连接池最大数量 -->
|
|
|
45
|
- <property name="maxActive" value="${jdbc.mysql.maxActive}"></property>
|
|
|
46
|
- <!-- 连接池最大空闲 -->
|
|
|
47
|
- <property name="maxIdle" value="${jdbc.mysql.maxIdle}"></property>
|
|
|
48
|
- <!-- 连接池最小空闲 -->
|
|
|
49
|
- <property name="minIdle" value="${jdbc.mysql.minIdle}"></property>
|
|
|
50
|
- <!-- 获取连接最大等待时间 -->
|
|
|
51
|
- <property name="maxWait" value="${jdbc.mysql.maxWait}"></property>
|
|
|
52
|
- <!--定时对线程池中的链接进行校验 -->
|
|
|
53
|
- <property name="testWhileIdle" value="${jdbc.mysql.testWhileIdle}"></property>
|
|
|
54
|
- <property name="timeBetweenEvictionRunsMillis" value="${jdbc.mysql.timeBetweenEvictionRunsMillis}"></property>
|
|
|
55
|
- <property name="validationQuery" value="${jdbc.mysql.validationQuery}"></property>
|
|
|
56
|
- <property name="testOnBorrow" value="${jdbc.mysql.testOnBorrow}"></property>
|
|
|
57
|
- <property name="testOnReturn" value="${jdbc.mysql.testOnReturn}"></property>
|
|
|
58
|
- </bean>
|
|
|
59
|
-
|
|
|
60
|
- <bean id="dynamicDataSource" class="com.yoho.core.dal.datasource.DynamicDataSource">
|
|
|
61
|
- <property name="defaultTargetDataSource" ref="yohobuylogsMasterDataSource" />
|
|
|
62
|
- <property name="targetDataSources">
|
|
|
63
|
- <map>
|
|
|
64
|
- <entry key="yohobuylogsMasterDataSource" value-ref="yohobuylogsMasterDataSource" />
|
|
|
65
|
- </map>
|
|
|
66
|
- </property>
|
|
|
67
|
- </bean>
|
|
|
68
|
-
|
|
|
69
|
- <bean id="multipleDataSourceRouter" class="com.yoho.core.dal.datasource.MultiDataSourceRouter">
|
|
|
70
|
- <property name="defaultDBCluster" value="yohobuylogsDbCluster" />
|
|
|
71
|
- <property name="readOnlyInSlave" value="${jdbc.mysql.readonlyinslave:false}" />
|
|
|
72
|
- <property name="dbClusterSet">
|
|
|
73
|
- <map>
|
|
|
74
|
- <entry key="yohobuylogsDbCluster" value="yohobuylogsMasterDataSource,yohobuylogsMasterDataSource" />
|
|
|
75
|
- </map>
|
|
|
76
|
- </property>
|
|
|
77
|
- <property name="daoDbClusterMap">
|
|
|
78
|
- <map>
|
|
|
79
|
-
|
|
|
80
|
- </map>
|
|
|
81
|
- </property>
|
|
|
82
|
- </bean>
|
|
|
83
|
-
|
|
|
84
|
- <bean id="dataSourceMethodInterceptor" class="com.yoho.core.dal.datasource.DataSourceMethodInterceptor">
|
|
|
85
|
- </bean>
|
|
|
86
|
-
|
|
|
87
|
- <aop:config>
|
|
|
88
|
- <aop:pointcut id="daoPoint" expression="execution(* com.yoho.*.dal.*.*(..)) " />
|
|
|
89
|
- <aop:advisor pointcut-ref="daoPoint" advice-ref="dataSourceMethodInterceptor" />
|
|
|
90
|
- </aop:config>
|
|
|
91
|
-
|
|
|
92
|
-
|
|
|
93
|
- <!-- spring和MyBatis完美整合,不需要mybatis的配置映射文件 -->
|
|
|
94
|
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
|
|
|
95
|
- <property name="dataSource" ref="dynamicDataSource" />
|
|
|
96
|
- <!-- 自动扫描mapping.xml文件 -->
|
|
|
97
|
- <property name="mapperLocations" value="classpath*:META-INF/mybatis/*.xml"></property>
|
|
|
98
|
- </bean>
|
|
|
99
|
- <!-- DAO接口所在包名,Spring会自动查找其下的类 -->
|
|
|
100
|
- <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
|
|
|
101
|
- <property name="basePackage" value="com.yoho.*.dal" />
|
|
|
102
|
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"></property>
|
|
|
103
|
- </bean>
|
|
|
104
|
-
|
|
|
105
|
-
|
|
|
106
|
-
|
|
|
107
|
-</beans> |
|
|