<?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:tx="http://www.springframework.org/schema/tx" xmlns:context="http://www.springframework.org/schema/context" 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-4.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task-4.0.xsd"> <context:annotation-config /> <context:component-scan base-package="com.fadu" /> <import resource="/application-mq.xml"/> <aop:aspectj-autoproxy/> <bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://rm-wz9279h6m7chow4151o.mysql.rds.aliyuncs.com:3306/duowen?useUnicode=true&characterEncoding=utf-8" /> <property name="user" value="wangxy" /> <property name="password" value="wangxy@88" /> <property name="acquireIncrement" value="3" /> <property name="idleConnectionTestPeriod" value="120" /> <property name="initialPoolSize" value="3" /> <property name="minPoolSize" value="2" /> <property name="maxPoolSize" value="5" /> <property name="numHelperThreads" value="3" /> <property name="preferredTestQuery" value="select 1" /> <property name="breakAfterAcquireFailure" value="false" /> <property name="testConnectionOnCheckout" value="false" /> <property name="testConnectionOnCheckin" value="false" /> <property name="acquireRetryAttempts" value="10" /> <property name="acquireRetryDelay" value="1000" /> <property name="maxIdleTime" value="600" /> </bean> <bean id="sessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.use_outer_join">true</prop> <prop key="hibernate.jdbc.fetch_size">30</prop> <prop key="hibernate.jdbc.batch_size">30</prop> <prop key="hibernate.jdbc.batch_versioned_data">true</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop> <prop key="hibernate.hbm2ddl.auto">update</prop> </props> </property> <property name="dataSource" ref="dataSource" /> <property name="packagesToScan"> <list> <value>com.fadu.springboot.model</value> </list> </property> </bean> <bean id="transactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="sessionFactory" /> </bean> <tx:annotation-driven transaction-manager="transactionManager" /> <bean id="beanFactoryHelper" class="com.fadu.app.util.BeanFactoryHelper"/> <tx:advice id="txAdvice" transaction-manager="transactionManager"> <tx:attributes> <tx:method name="get*" read-only="true" propagation="REQUIRED" /> <tx:method name="count*" read-only="true" propagation="REQUIRED" /> <tx:method name="find*" read-only="true" propagation="REQUIRED" /> <tx:method name="list*" read-only="true" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <bean id="appDataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource" destroy-method="close"> <property name="driverClass" value="com.mysql.jdbc.Driver" /> <property name="jdbcUrl" value="jdbc:mysql://rm-wz9279h6m7chow4151o.mysql.rds.aliyuncs.com:3306/duowen?useUnicode=true&characterEncoding=utf-8" /> <property name="user" value="wangxy" /> <property name="password" value="wangxy@88" /> <property name="acquireIncrement" value="3" /> <property name="idleConnectionTestPeriod" value="120" /> <property name="initialPoolSize" value="1" /> <property name="minPoolSize" value="1" /> <property name="maxPoolSize" value="3" /> <property name="numHelperThreads" value="3" /> <property name="preferredTestQuery" value="select 1" /> </bean> <bean id="appSessionFactory" class="org.springframework.orm.hibernate4.LocalSessionFactoryBean"> <property name="hibernateProperties"> <props> <prop key="hibernate.dialect">org.hibernate.dialect.MySQL5Dialect</prop> <prop key="hibernate.show_sql">false</prop> <prop key="hibernate.use_outer_join">true</prop> <prop key="hibernate.jdbc.fetch_size">30</prop> <prop key="hibernate.jdbc.batch_size">30</prop> <prop key="hibernate.jdbc.batch_versioned_data">true</prop> <prop key="hibernate.cache.use_second_level_cache">false</prop> <prop key="hibernate.cache.use_query_cache">true</prop> <prop key="hibernate.cache.provider_class">net.sf.ehcache.hibernate.SingletonEhCacheProvider</prop> <prop key="hibernate.cache.region.factory_class">org.hibernate.cache.ehcache.SingletonEhCacheRegionFactory</prop> <prop key="hibernate.current_session_context_class">org.springframework.orm.hibernate4.SpringSessionContext</prop> <!-- --> <prop key="hibernate.hbm2ddl.auto">none</prop> </props> </property> <property name="dataSource" ref="appDataSource" /> <property name="packagesToScan"> <list> <value>com.fadu.springboot.model</value> </list> </property> </bean> <bean id="appTransactionManager" class="org.springframework.orm.hibernate4.HibernateTransactionManager"> <property name="sessionFactory" ref="appSessionFactory" /> </bean> <tx:advice id="appTxAdvice" transaction-manager="appTransactionManager"> <tx:attributes> <tx:method name="get*" read-only="true" propagation="REQUIRED" /> <tx:method name="count*" read-only="true" propagation="REQUIRED" /> <tx:method name="find*" read-only="true" propagation="REQUIRED" /> <tx:method name="list*" read-only="true" propagation="REQUIRED"/> <tx:method name="*" propagation="REQUIRED" /> </tx:attributes> </tx:advice> <aop:config> <aop:pointcut expression="execution(public * com.fadu.*.service..*.*(..))" id="bussinessService" /> <aop:advisor advice-ref="txAdvice" pointcut-ref="bussinessService" /> <aop:advisor advice-ref="appTxAdvice" pointcut-ref="bussinessService" /> </aop:config> <!-- 加载文件 --> <context:property-placeholder location="classpath:redis.properties" /> <!-- jedis 配置 --> <bean id="poolConfig" 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> <!-- redis服务器中心 --> <bean id="connectionFactory" class="org.springframework.data.redis.connection.jedis.JedisConnectionFactory"> <property name="poolConfig" ref="poolConfig" /> <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> <!-- redis操作模板,面向对象的模板 --> <bean id="redisTemplate" class="org.springframework.data.redis.core.StringRedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <!--如果不配置Serializer,那么存储的时候只能使用String,如果用对象类型存储,那么会提示错误--> <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="stringRedisSerializer" class="org.springframework.data.redis.serializer.StringRedisSerializer"/> <!-- redis模板 --> <bean id="redis" class="org.springframework.data.redis.core.RedisTemplate"> <property name="connectionFactory" ref="connectionFactory" /> <property name="keySerializer" ref="stringRedisSerializer"/> <property name="valueSerializer" > <bean class="org.springframework.data.redis.serializer.JacksonJsonRedisSerializer"> <constructor-arg type="java.lang.Class" value="java.lang.Object"/> </bean> </property> </bean> <!-- 定时器配置--> <task:annotation-driven /> <!-- 扫描任务 --> <context:component-scan base-package="com.fadu.app.schedule" /> <!-- 定时任务 --> <!-- <task:scheduler id="myScheduler"/> <task:scheduled-tasks scheduler="myScheduler"> <task:scheduled ref="adminJob" method="jobAdvOrderOvertimeRefund" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adminJob" method="jobAdvOrderArrivalTimeAndPushMsg" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adminJob" method="jobpushBroadcastMsgToLawyer" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adminJob" method="jobAdvOrderArrivalTimeAndPushEvaluate" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adminJob" method="jobPublishNewOrder" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adminJob" method="jobUpdateAccountToLawyer" cron="0 0/20 * * * ?" /> <!– 20分钟轮训 –> <task:scheduled ref="adminJob" method="jobAdvOrderArrivalTimeAutoComment" cron="0 0/1 * * * ?" /><!– 1分钟轮训TODO:时间需要调控 –> <task:scheduled ref="adminJob" method="jobAdvOrderOvertimeProvideLawyerPhone" cron="0 0/1 * * * ?" /><!– 1分钟轮训TODO:后续集成消息框架 –> <task:scheduled ref="adsAdminJob" method="jobAdsOrderOvertimeProvideLawyerPhone" cron="0 0/1 * * * ?" /><!– 1分钟轮训TODO:后续集成消息框架 –> <task:scheduled ref="adsAdminJob" method="jobAdsOrderArrivalTimeAndPushMsg" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adsAdminJob" method="jobAdsOrderArrivalTimeAndPushEvaluate" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> <task:scheduled ref="adsAdminJob" method="jobAdsOrderArrivalTimeAutoComment" cron="0 0/1 * * * ?" /><!– 1分钟轮训TODO:时间需要调控 –> <task:scheduled ref="adsAdminJob" method="jobUpdateAccountToLawyer" cron="0 0/20 * * * ?" /> <!– 20分钟轮训 –> <task:scheduled ref="adsAdminJob" method="pushNoRewardCard" cron="0 0/1 * * * ?" /><!– 1分钟轮训 –> </task:scheduled-tasks> --> </beans>