data-source.xml
3.67 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
<?xml version="1.0" encoding="UTF-8" ?>
<beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://www.springframework.org/schema/beans"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- DBCP连接池 -->
<bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="defaultAutoCommit" value="false" />
<property name="filters" value="config" />
<property name="connectionProperties" value="config.decrypt=true" />
<property name="maxActive" value="200" />
<!--<property name="connectionInitSqls" value="set names utf8mb4;"/>-->
</bean>
<!-- TransactionManager定义 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- 使用annotation定义事务 -->
<tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true" />
<!-- MyBatis配置 -->
<bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="dataSource" />
<!-- 自动扫描模型对象目录, 省掉Configuration.xml里的手工配置, 改为明确的控制
<property name="typeAliasesPackage" value="com.xniu.xxx.contract" /> -->
<!-- 指定Mapper文件位置 -->
<property name="mapperLocations" value="classpath:/mapper/*/*.xml"/>
<property name="configLocation" value="classpath:/mybatis_setting.xml" />
<property name="configurationProperties">
<props>
<prop key="mapUnderscoreToCamelCase">true</prop>
<prop key="aggressiveLazyLoading">false</prop>
<prop key="cacheEnabled">true</prop>
<prop key="useColumnLabel">true</prop>
<!--<prop key="useGeneratedKeys">true</prop>-->
</props>
</property>
</bean>
<!-- 扫描basePackage下所有以@MyBatisRepository标识的 接口-->
<bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="basePackage" value="com.xiniunet.service.*.dal" />
<property name="annotationClass" value="com.xiniunet.framework.annotation.MyBatisRepository"/>
</bean>
<bean id="dbPropertyConfigurer" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="order" value="1" />
<property name="ignoreUnresolvablePlaceholders" value="true" />
<property name="locations">
<list>
<value>classpath*:/jdbc.properties</value>
<value>classpath*:/setting.properties</value>
</list>
</property>
</bean>
<bean id="cacheManager" class="com.xiniunet.framework.cache.CacheManagerImpl">
<constructor-arg value="${aliyun.ocs.host}"/>
<constructor-arg value="${aliyun.ocs.port}"/>
<constructor-arg value="${deploy.mode}"/>
<constructor-arg value="${aliyun.ocs.username}"/>
<constructor-arg value="${aliyun.ocs.password}"/>
</bean>
<bean id="cacheAop" class="com.xiniunet.framework.cache.CacheAop">
</bean>
</beans>