applicationContext.xml
6.1 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
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
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
<?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:aop="http://www.springframework.org/schema/aop" xmlns:tx="http://www.springframework.org/schema/tx"
xmlns:jpa="http://www.springframework.org/schema/data/jpa"
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/aop
http://www.springframework.org/schema/aop/spring-aop.xsd
http://www.springframework.org/schema/tx
http://www.springframework.org/schema/tx/spring-tx.xsd
http://www.springframework.org/schema/data/jpa
http://www.springframework.org/schema/data/jpa/spring-jpa.xsd">
<!-- 配置此项可以使用Annotation -->
<context:annotation-config />
<!-- 扫描包 -->
<context:component-scan
base-package="com.framework.mail,com.agent.service,com.agent.repository" />
<!-- 使用Aop -->
<aop:aspectj-autoproxy />
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:datasource.properties</value>
<value>classpath:application.properties</value>
</list>
</property>
</bean>
<!-- 配置DataSource 使用Druid连接池 -->
<bean id="dataSource" init-method="init" destroy-method="close"
class="com.alibaba.druid.pool.DruidDataSource">
<property name="DriverClassName" value="${jdbc.driverClassName}" />
<property name="url" value="${jdbc.url}" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<!-- 连接池最大使用连接数量 -->
<property name="maxActive" value="${maxActive}" />
<!-- 初始化大小 -->
<property name="initialSize" value="${initialSize}" />
<!-- 获取连接最大等待时间 -->
<property name="maxWait" value="${maxWait}" />
<!-- 连接池最小空闲 -->
<property name="minIdle" value="${minIdle}" />
<!-- 逐出连接的检测时间间隔 -->
<property name="timeBetweenEvictionRunsMillis" value="${timeBetweenEvictionRunsMillis}" />
<!-- 最小逐出时间 -->
<property name="minEvictableIdleTimeMillis" value="${minEvictableIdleTimeMillis}" />
<!-- 测试有效用的SQL Query <property name="validationQuery" value="SELECT 1"
/> -->
<!-- 连接空闲时测试是否有效 -->
<property name="testWhileIdle" value="true" />
<!-- 获取连接时测试是否有效 -->
<property name="testOnBorrow" value="false" />
<!-- 归还连接时是否测试有效 -->
<property name="testOnReturn" value="false" />
</bean>
<!-- Jpa Entity Manager 配置 -->
<bean id="entityManagerFactory"
class="org.springframework.orm.jpa.LocalContainerEntityManagerFactoryBean">
<property name="dataSource" ref="dataSource" />
<property name="jpaVendorAdapter" ref="hibernateJpaVendorAdapter" />
<property name="packagesToScan" value="com.agent.entity" />
<property name="jpaProperties">
<props>
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.EhCacheRegionFactory</prop>
<prop key="net.sf.ehcache.configurationResourceName">cache/ehcache-hibernate-local.xml</prop>
<prop key="hibernate.ejb.naming_strategy">org.hibernate.cfg.ImprovedNamingStrategy</prop>
<prop key="hibernate.show_sql">${showSql}</prop>
<prop key="hibernate.format_sql">${formatSql}</prop>
<prop key="hibernate.hbm2ddl.auto">${generateDdl}</prop>
</props>
</property>
</bean>
<bean id="hibernateJpaVendorAdapter"
class="org.springframework.orm.jpa.vendor.HibernateJpaVendorAdapter">
<property name="databasePlatform">
<bean factory-method="getDialect" class="com.framework.core.Hibernates">
<constructor-arg ref="dataSource" />
</bean>
</property>
</bean>
<!-- 事务配置 Start -->
<bean id="transactionManager" class="org.springframework.orm.jpa.JpaTransactionManager">
<property name="entityManagerFactory" ref="entityManagerFactory" />
</bean>
<tx:annotation-driven transaction-manager="transactionManager"
proxy-target-class="true" />
<!-- 事务配置End -->
<!-- spring data jpa -->
<jpa:repositories base-package="com.agent.repository"
entity-manager-factory-ref="entityManagerFactory"
transaction-manager-ref="transactionManager">
</jpa:repositories>
<bean id="jdbcTemplate" class="org.springframework.jdbc.core.JdbcTemplate">
<property name="dataSource" ref="dataSource" />
</bean>
<!-- velocity 模板引擎 -->
<bean id="velocityEngine"
class="org.springframework.ui.velocity.VelocityEngineFactoryBean">
<property name="velocityProperties">
<props>
<prop key="resource.loader">file</prop>
<prop key="file.resource.loader.class">org.apache.velocity.runtime.resource.loader.ClasspathResourceLoader</prop>
<prop key="file.resource.loader.cache">false</prop>
<prop key="file.resource.loader.modificationCheckInterval">3</prop>
<prop key="input.encoding">UTF-8</prop>
<prop key="output.encoding">UTF-8</prop>
</props>
</property>
</bean>
<!-- 配置邮件 senderbean -->
<bean id="mailSender" class="org.springframework.mail.javamail.JavaMailSenderImpl">
<property name="host" value="${mail.smtp.host}"></property>
<property name="javaMailProperties">
<props>
<prop key="mail.smtp.auth">${mail.smtp.auth}</prop>
<prop key="mail.smtp.timeout">${mail.smtp.timeout}</prop>
</props>
</property>
<property name="username" value="${mail.smtp.username}"></property>
<property name="password" value="${mail.smtp.password}"></property>
</bean>
<bean id="org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl"
class="org.apache.cxf.wstx_msv_validation.WoodstoxValidationImpl"
lazy-init="true">
<constructor-arg ref="cxf" />
</bean>
<bean id="startupListener" class="com.agent.listener.StartupListener"/>
<bean id="SpringContextKit" class="com.agent.billcheck.SpringContextKit" scope="singleton"></bean>
</beans>