spring-mybatis.xml
2.65 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
<?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:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.1.xsd">
<!-- dataSource -->
<bean id="cmdbDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass">
<value>com.mysql.jdbc.Driver</value>
</property>
<property name="jdbcUrl">
<value>${local.jdbc.url}</value>
</property>
<property name="user">
<value>${local.jdbc.user}</value>
</property>
<property name="password">
<value>${local.jdbc.password}</value>
</property>
<property name="checkoutTimeout" value="3000"/>
<property name="acquireIncrement" value="2"/>
<property name="maxPoolSize" value="40"/>
<property name="minPoolSize" value="5"/>
</bean>
<!-- dataSource -->
<!--mybatis -->
<bean id="cmdbSqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<property name="dataSource" ref="cmdbDataSource"/>
<property name="configLocation" value="classpath:META-INF/mybatis/mybatis-config.xml"/>
<property name="typeAliasesPackage" value="com.model"/>
<property name="transactionFactory">
<bean class="org.mybatis.spring.transaction.SpringManagedTransactionFactory"/>
</property>
</bean>
<!--配置Mybatis模版 -->
<bean id="cmdbSqlSessionTemplate" class="org.mybatis.spring.SqlSessionTemplate">
<constructor-arg index="0" ref="cmdbSqlSessionFactory"/>
</bean>
<bean id="cmdbMapperScan" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<property name="sqlSessionFactoryBeanName" value="cmdbSqlSessionFactory"></property>
<property name="sqlSessionTemplateBeanName" value="cmdbSqlSessionTemplate"></property>
<property name="basePackage" value="com.monitor.mysql.mapper"/>
</bean>
<bean id="cmdbTxManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="cmdbDataSource"/>
</bean>
<bean id="cmdbTransactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<property name="dataSource" ref="cmdbDataSource"/>
</bean>
<tx:annotation-driven transaction-manager="cmdbTxManager"/>
</beans>