-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapplicationContext.xml
65 lines (59 loc) · 3.32 KB
/
applicationContext.xml
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="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:context="http://www.springframework.org/schema/context" 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/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd">
<!-- B:配置数据源 -->
<!-- B:导入数据源配置的资源文件 -->
<context:property-placeholder location="classpath:db.properties"/>
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="user" value="${jdbc.user}"/>
<property name="password" value="${jdbc.password}"/>
<property name="driverClass" value="${jdbc.driverClass}"/>
<property name="jdbcUrl" value="${jdbc.jdbcUrl}"/>
<property name="initialPoolSize" value="${jdbc.initPoolSize}"/>
<property name="maxPoolSize" value="${jdbc.maxPoolSize}"/>
</bean>
<!-- E:配置数据源 -->
<!-- E:导入数据源配置的资源文件 -->
<!-- B:配置Hibernate的SessionFactory实例 :通过spring提供的LocalSessionFactoryBean进行配置-->
<bean id="sessionFactory" class="org.springframework.orm.hibernate5.LocalSessionFactoryBean">
<!-- 配置数据源属性 -->
<property name="dataSource" ref="dataSource"/>
<!-- 配置hibernate配置文件的位置及名称 -->
<property name="configLocation" value="classpath:hibernate.cfg.xml"/>
<!-- 配置hibernate映射文件的位置及名称,可以使用通配符,有两种方式 -->
<!-- 方法1
<property name="mappingLocations" value="classpath:com/aimeng/security/domain/*.hbm.xml"></property>
-->
<!-- 方法2 -->
<property name="packagesToScan">
<array>
<value>com.his.surgery.entity</value>
</array>
</property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.connection.url">jdbc:mysql://localhost:3306</prop>
<prop key="hibernate.connection.driver_class">com.mysql.jdbc.Driver</prop>
</props>
</property>
</bean>
<!-- E:配置Hibernate的SessionFactory实例 :通过spring提供的LocalSessionFactoryBean进行配置-->
<!-- B:配置spring事物式声明 -->
<!-- 1、配置事物管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate5.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"/>
</bean>
<!-- 2、启用事务注解 -->
<tx:annotation-driven transaction-manager="transactionManager"/>
<!-- D:配置spring事务式声明 -->
<!-- 启用注解 -->
<context:annotation-config />
<!-- dao层扫描器 -->
<context:component-scan base-package="com.his.surgery.daoImpl" />
<!-- service层扫描器 -->
<context:component-scan base-package="com.his.surgery.serviceImpl" />
<!-- action层扫描器 -->
<context:component-scan base-package="com.his.surgery.action" />
</beans>