-
Notifications
You must be signed in to change notification settings - Fork 22
/
Copy pathapplicationContext.xml
97 lines (89 loc) · 3.3 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:context="http://www.springframework.org/schema/context"
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="autodetect">
<!-- 加载配置文件 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:jdbc.properties</value>
<value>classpath:hibernate.properties</value>
</list>
</property>
</bean>
<!-- 加载jndi数据源 -->
<bean id="dataSource"
class="org.springframework.jndi.JndiObjectFactoryBean"
autowire="no">
<property name="jndiName" value="${jdbc.jndiName}"></property>
<property name="cache" value="true"></property>
</bean>
<!-- 在spring中配置hibernate -->
<bean id="sessionFactory"
class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="dataSource" ref="dataSource"></property>
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">
${hibernate.dialect}
</prop>
<prop key="hibernate.transaction.factory_class">
${hibernate.transaction.factory_class}
</prop>
<prop key="hibernate.show_sql">
${hibernate.show_sql}
</prop>
<prop key="hibernate.cache.provider_class">
${hibernate.cache.provider_class}
</prop>
<prop key="hibernate.cache.use_second_level_cache">
${hibernate.cache.use_second_level_cache}
</prop>
<prop key="hibernate.cache.use_query_cache">
${hibernate.cache.use_query_cache}
</prop>
</props>
</property>
<property name="mappingDirectoryLocations">
<list>
<value>classpath:/com/rbac/entity</value>
</list>
</property>
</bean>
<!-- 自动将这些包下的类封装为spring bean -->
<context:component-scan base-package="com.rbac.dao">
</context:component-scan>
<context:component-scan base-package="com.rbac.service">
</context:component-scan>
<bean id="baseDaoSupport" class="com.rbac.common.BaseDaoSupport">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean>
<tx:advice id="txAdvice">
<tx:attributes>
<tx:method name="*" />
</tx:attributes>
</tx:advice>
<!-- 以AspectJ方式 定义 AOP -->
<aop:config proxy-target-class="true">
<aop:advisor
pointcut="execution(* com.rbac.service.*.*Service.*(..))"
advice-ref="txAdvice" />
</aop:config>
<!-- 支持 @Transactional 标记 -->
<tx:annotation-driven proxy-target-class="true"
transaction-manager="transactionManager" />
<!-- 配置事务管理器 -->
<bean id="transactionManager"
class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory" />
</bean>
</beans>