data-source.xml
3.33 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
<?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">
<!-- ======================================================================== -->
<!-- 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.lecuntao.ordering.*.dal"/>
<property name="annotationClass" value="com.xiniunet.framework.annotation.MyBatisRepository"/>
</bean>
<!--location="classpath*:/omp/dal/jdbc.development.properties" />-->
<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>
</list>
</property>
</bean>
<!-- 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" />
</bean>
</beans>