forked from guomin/QRORDER
210 lines
9.4 KiB
XML
210 lines
9.4 KiB
XML
|
|
<?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:p="http://www.springframework.org/schema/p"
|
||
|
|
xmlns:context="http://www.springframework.org/schema/context"
|
||
|
|
xmlns:mvc="http://www.springframework.org/schema/mvc"
|
||
|
|
xmlns:cache="http://www.springframework.org/schema/cache"
|
||
|
|
xmlns:tx="http://www.springframework.org/schema/tx"
|
||
|
|
xmlns:aop="http://www.springframework.org/schema/aop"
|
||
|
|
xmlns:task="http://www.springframework.org/schema/task"
|
||
|
|
xsi:schemaLocation="http://www.springframework.org/schema/beans
|
||
|
|
http://www.springframework.org/schema/beans/spring-beans-3.1.xsd
|
||
|
|
http://www.springframework.org/schema/context
|
||
|
|
http://www.springframework.org/schema/context/spring-context-3.1.xsd
|
||
|
|
http://www.springframework.org/schema/mvc
|
||
|
|
http://www.springframework.org/schema/mvc/spring-mvc-4.0.xsd
|
||
|
|
http://www.springframework.org/schema/tx
|
||
|
|
http://www.springframework.org/schema/tx/spring-tx-3.0.xsd
|
||
|
|
http://www.springframework.org/schema/cache
|
||
|
|
http://www.springframework.org/schema/cache/spring-cache-3.2.xsd
|
||
|
|
http://www.springframework.org/schema/aop
|
||
|
|
http://www.springframework.org/schema/aop/spring-aop.xsd
|
||
|
|
http://www.springframework.org/schema/task
|
||
|
|
http://www.springframework.org/schema/task/spring-task.xsd
|
||
|
|
">
|
||
|
|
|
||
|
|
<context:component-scan base-package="com.bettersoft.**.controllers"
|
||
|
|
use-default-filters="false">
|
||
|
|
<context:include-filter type="annotation"
|
||
|
|
expression="org.springframework.stereotype.Controller" />
|
||
|
|
</context:component-scan>
|
||
|
|
<context:component-scan base-package="com.bettersoft.**.*service" />
|
||
|
|
<context:component-scan base-package="com.bettersoft.**.dao.implement" />
|
||
|
|
<context:component-scan base-package="com.bettersoft.api.websocket" />
|
||
|
|
<context:component-scan base-package="com.bettersoft.api.config" />
|
||
|
|
|
||
|
|
<context:property-placeholder location="classpath*:jdbc.properties,classpath*:config.properties,classpath*:redis.properties" />
|
||
|
|
|
||
|
|
<bean id="configParamHelper" class="com.bettersoft.api.utils.ConfigParamHelper"/>
|
||
|
|
|
||
|
|
<!-- FOR ORACLE -->
|
||
|
|
<bean id="nativeJdbcExtractor" lazy-init="true"
|
||
|
|
class="org.springframework.jdbc.support.nativejdbc.C3P0NativeJdbcExtractor" />
|
||
|
|
|
||
|
|
<!-- 以下配置在weblogic上使用 JNDI数据源 -->
|
||
|
|
<!-- <bean id="dataSource" class="org.springframework.jndi.JndiObjectFactoryBean">
|
||
|
|
<property name="jndiName"> <value>DS_BSVMS</value> </property> </bean> -->
|
||
|
|
<!-- -->
|
||
|
|
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"
|
||
|
|
destroy-method="close">
|
||
|
|
<property name="driverClass" value="${jdbc.driverClassName}" />
|
||
|
|
<property name="jdbcUrl" value="${jdbc.url}" />
|
||
|
|
<property name="user" value="${jdbc.username}" />
|
||
|
|
<property name="password" value="${jdbc.password}" />
|
||
|
|
<property name="acquireIncrement" value="1" />
|
||
|
|
<property name="initialPoolSize" value="5" />
|
||
|
|
<property name="maxStatements" value="0" />
|
||
|
|
<property name="maxIdleTime" value="60" />
|
||
|
|
<property name="maxPoolSize" value="${jdbc.maxPoolSize}" />
|
||
|
|
<property name="minPoolSize" value="5" />
|
||
|
|
<property name="acquireRetryDelay" value="1000" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<!-- REDIS数据源配置 -->
|
||
|
|
<bean id="redisPoolConfig" class="redis.clients.jedis.JedisPoolConfig">
|
||
|
|
<property name="maxIdle" value="${redis.maxIdle}" />
|
||
|
|
<property name="minIdle" value="${redis.minIdle}" />
|
||
|
|
<property name="maxWaitMillis" value="${redis.maxWait}" />
|
||
|
|
<property name="testOnBorrow" value="${redis.testOnBorrow}" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory">
|
||
|
|
<property name="poolConfig" ref="redisPoolConfig" />
|
||
|
|
<property name="port" value="${redis.port}" />
|
||
|
|
<property name="hostName" value="${redis.host}" />
|
||
|
|
<property name="password" value="${redis.pass}" />
|
||
|
|
<property name="timeout" value="${redis.timeout}" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<bean id="redisTemplate" class="org.springframework.data.redis.core.RedisTemplate">
|
||
|
|
<property name="connectionFactory" ref="connectionFactory" />
|
||
|
|
<!-- 序列化方式 建议key/hashKey采用StringRedisSerializer -->
|
||
|
|
<property name="keySerializer">
|
||
|
|
<bean
|
||
|
|
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
<property name="valueSerializer">
|
||
|
|
<bean
|
||
|
|
class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
<property name="hashKeySerializer">
|
||
|
|
<bean
|
||
|
|
class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
<property name="hashValueSerializer">
|
||
|
|
<bean
|
||
|
|
class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
<!-- 开启REIDS事务支持 -->
|
||
|
|
<property name="enableTransactionSupport" value="false" />
|
||
|
|
</bean>
|
||
|
|
<!--
|
||
|
|
<bean id="stringRedisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate">
|
||
|
|
<property name="connectionFactory" ref="connectionFactory" />
|
||
|
|
<property name="keySerializer">
|
||
|
|
<bean class="org.springframework.data.redis.serializer.StringRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
<property name="valueSerializer">
|
||
|
|
<bean class="org.springframework.data.redis.serializer.JdkSerializationRedisSerializer" />
|
||
|
|
</property>
|
||
|
|
</bean>
|
||
|
|
-->
|
||
|
|
|
||
|
|
<bean id="redisCacheUtil" class="com.bettersoft.api.utils.RedisCacheUtil">
|
||
|
|
<property name="redisTemplate" ref="redisTemplate"></property>
|
||
|
|
<!-- <property name="stringRedisTemplate" ref="stringRedisTemplate"></property> -->
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<!-- <bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean"> -->
|
||
|
|
<bean id="sessionFactory"
|
||
|
|
class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
|
||
|
|
<property name="hibernateProperties">
|
||
|
|
<props>
|
||
|
|
<prop key="hibernate.dialect">${hibernate.dialect}</prop>
|
||
|
|
<prop key="hibernate.query.substitutions">true=1 false=0</prop>
|
||
|
|
<prop key="hibernate.show_sql">${hibernate.show_sql}</prop>
|
||
|
|
<prop key="hibernate.format_sql">true</prop>
|
||
|
|
<prop key="hibernate.hbm2ddl.auto">false</prop>
|
||
|
|
<prop key="hibernate.use_outer_join">true</prop>
|
||
|
|
<prop key="hibernate.max_fetch_depth">3</prop>
|
||
|
|
<prop key="hibernate.enable_lazy_load_no_trans">true</prop>
|
||
|
|
<prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext
|
||
|
|
</prop>
|
||
|
|
<prop key="hibernate.cache.use_query_cache">true</prop>
|
||
|
|
<prop key="hibernate.cache.region.factory_class">org.hibernate.cache.SingletonEhCacheRegionFactory
|
||
|
|
</prop>
|
||
|
|
<prop key="hibernate.cache.use_second_level_cache">true</prop>
|
||
|
|
<prop key="hibernate.transaction.factory_class">org.hibernate.transaction.JDBCTransactionFactory
|
||
|
|
</prop>
|
||
|
|
<prop key="hibernate.cglib.use_reflection_optimizer">true</prop>
|
||
|
|
</props>
|
||
|
|
</property>
|
||
|
|
<property name="dataSource" ref="dataSource" />
|
||
|
|
<property name="packagesToScan" value="com.bettersoft.api.model"></property>
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<bean id="hibernateTemplate" class="org.springframework.orm.hibernate4.HibernateTemplate">
|
||
|
|
<property name="sessionFactory" ref="sessionFactory"></property>
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<bean id="cacheManager"
|
||
|
|
class="org.springframework.cache.ehcache.EhCacheManagerFactoryBean">
|
||
|
|
<property name="configLocation" value="classpath:ehcache.xml"></property>
|
||
|
|
<property name="shared" value="true" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<bean id="ehcache" class="org.springframework.cache.ehcache.EhCacheCacheManager">
|
||
|
|
<property name="cacheManager" ref="cacheManager" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<cache:annotation-driven cache-manager="ehcache" />
|
||
|
|
|
||
|
|
<bean id="transactionManager"
|
||
|
|
class="org.springframework.orm.hibernate4.HibernateTransactionManager"
|
||
|
|
p:sessionFactory-ref="sessionFactory" />
|
||
|
|
<!--<tx:annotation-driven transaction-manager="transactionManager" />-->
|
||
|
|
<tx:annotation-driven proxy-target-class="true" transaction-manager="transactionManager" />
|
||
|
|
<tx:advice id="txAdvice" transaction-manager="transactionManager">
|
||
|
|
<tx:attributes>
|
||
|
|
<tx:method name="*" propagation="REQUIRED" read-only="true" />
|
||
|
|
</tx:attributes>
|
||
|
|
</tx:advice>
|
||
|
|
|
||
|
|
<mvc:annotation-driven>
|
||
|
|
<mvc:message-converters>
|
||
|
|
<bean class="org.springframework.http.converter.StringHttpMessageConverter" />
|
||
|
|
</mvc:message-converters>
|
||
|
|
</mvc:annotation-driven>
|
||
|
|
<mvc:annotation-driven validator="validator" />
|
||
|
|
|
||
|
|
<task:executor id="executor" pool-size="10" />
|
||
|
|
<task:annotation-driven executor="executor" />
|
||
|
|
|
||
|
|
<bean id="validator"
|
||
|
|
class="org.springframework.validation.beanvalidation.LocalValidatorFactoryBean">
|
||
|
|
<property name="providerClass" value="org.hibernate.validator.HibernateValidator" />
|
||
|
|
<property name="validationMessageSource" ref="messageSource" />
|
||
|
|
</bean>
|
||
|
|
<bean id="messageSource"
|
||
|
|
class="org.springframework.context.support.ReloadableResourceBundleMessageSource">
|
||
|
|
<property name="basenames">
|
||
|
|
<list>
|
||
|
|
<value>classpath:validatemessage</value>
|
||
|
|
</list>
|
||
|
|
</property>
|
||
|
|
<property name="defaultEncoding" value="utf-8" />
|
||
|
|
<property name="cacheSeconds" value="120" />
|
||
|
|
</bean>
|
||
|
|
|
||
|
|
<aop:config>
|
||
|
|
<aop:pointcut id="txPoint"
|
||
|
|
expression="execution(* com.bettersoft.api.service.*.*(..))" />
|
||
|
|
<aop:advisor advice-ref="txAdvice" pointcut-ref="txPoint" />
|
||
|
|
</aop:config>
|
||
|
|
|
||
|
|
<bean
|
||
|
|
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping" />
|
||
|
|
<bean
|
||
|
|
class="org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerAdapter" />
|
||
|
|
</beans>
|