-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapplicationContext.xml
More file actions
58 lines (52 loc) · 2.92 KB
/
applicationContext.xml
File metadata and controls
58 lines (52 loc) · 2.92 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
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:p="http://www.springframework.org/schema/p"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-2.5.xsd"
default-autowire="no">
<!-- 解析db.properties -->
<context:property-placeholder location="classpath:db.properties"/>
<!--数据源 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="jdbcUrl" value="${db.jdbcUrl}"></property>
<property name="driverClass" value="${db.driverClass}"></property>
<property name="user" value="${db.user}"></property>
<property name="password" value="${db.password}"></property>
<property name="maxPoolSize" value="40"></property>
<property name="minPoolSize" value="1"></property>
<property name="initialPoolSize" value="1"></property>
<property name="maxIdleTime" value="30"></property>
<property name="checkoutTimeout" value="6000"></property>
</bean>
<!-- session工厂 -->
<bean id="sessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
<!--注入数据源 -->
<property name="dataSource" ref="dataSource"></property>
<!-- 引入mybatis-config.xml配置文件-->
<property name="configLocation" value="classpath:mybatis-config.xml"></property>
</bean>
<!-- mapper接口 -->
<bean id="mapperscan" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
<!-- 配置sessionfactory-->
<property name="sqlSessionFactoryBeanName" value="sessionFactory"></property>
<!--扫描mapper接口 -->
<property name="basePackage" value="dao"></property>
</bean>
<!-- 配置事务管理 -->
<bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
<!-- 注入数据源 -->
<property name="dataSource" ref="dataSource"></property>
</bean>
<!--开启事务管理驱动 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
</beans>