123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150 |
- <?xml version="1.0" encoding="UTF-8"?>
- <beans xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:aop="http://www.springframework.org/schema/aop"
- xmlns:context="http://www.springframework.org/schema/context"
- xmlns="http://www.springframework.org/schema/beans"
- xsi:schemaLocation="http://www.springframework.org/schema/beans
- http://www.springframework.org/schema/beans/spring-beans.xsd
- http://www.springframework.org/schema/tx
- http://www.springframework.org/schema/tx/spring-tx.xsd
- http://www.springframework.org/schema/aop
- http://www.springframework.org/schema/aop/spring-aop.xsd
- http://www.springframework.org/schema/context
- http://www.springframework.org/schema/context/spring-context.xsd">
- <context:component-scan base-package="com.yc.education.service"/>
- <context:property-placeholder location="classpath:config.properties"/>
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="driverClassName" value="${jdbc.driverClass}"/>
- <property name="url" value="${jdbc.url}"/>
- <property name="username" value="${jdbc.user}"/>
- <property name="password" value="${jdbc.password}"/>
- <!-- <property name="connectionInitSqls" value="${jdbc.arr}"/>-->
- <property name="filters" value="stat"/>
- <!-- 最大链接数 -->
- <property name="maxActive" value="2000"/>
- <!-- 初始化链接 -->
- <property name="initialSize" value="10"/>
- <!-- 从池中取连接的最大等待时间,单位ms. -->
- <property name="maxWait" value="60000"/>
- <!-- 最小空闲连接 -->
- <property name="minIdle" value="1"/>
- <!-- 每一分钟运行一次空闲连接回收器 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000"/>
- <!-- 池中的连接空闲6分钟后被回收 -->
- <property name="minEvictableIdleTimeMillis" value="300000"/>
- <!-- 超时时间;单位为秒。180秒=3分钟 -->
- <property name="removeAbandonedTimeout" value="180"/>
- <!-- 关闭abanded连接时输出错误日志 -->
- <property name="logAbandoned" value="true"/>
- <!-- 超过时间限制是否回收 -->
- <property name="removeAbandoned" value="true"/>
- <property name="validationQuery" value="SELECT 'x'"/>
- <property name="testWhileIdle" value="true"/>
- <property name="testOnBorrow" value="false"/>
- <property name="testOnReturn" value="false"/>
- </bean>
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="configLocation" value="classpath:mybatis-config.xml"/>
- <property name="dataSource" ref="dataSource"/>
- <property name="mapperLocations">
- <array>
- <value>classpath:mapper/*.xml</value>
- </array>
- </property>
- <property name="typeAliasesPackage" value="com.yc.education.model"/>
- <property name="plugins">
- <array>
- <bean class="com.github.pagehelper.PageHelper">
- <!-- 这里的几个配置主要演示如何使用,如果不理解,一定要去掉下面的配置 -->
- <property name="properties">
- <value>
- dialect=mysql
- reasonable=true
- supportMethodsArguments=true
- params=count=countSql
- autoRuntimeDialect=true
- </value>
- </property>
- </bean>
- </array>
- </property>
- </bean>
- <bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="basePackage" value="com.yc.education.mapper"/>
- <!-- 3.2.2版本新特性,markerInterface可以起到mappers配置的作用,详细情况需要看Marker接口类 -->
- <property name="markerInterface" value="com.yc.education.util.MyMapper"/>
- <!-- 通用Mapper通过属性注入进行配置,默认不配置时会注册Mapper<T>接口
- <property name="properties">
- <value>
- mappers=tk.mybatis.mapper.common.Mapper
- </value>
- </property>
- -->
- </bean>
- <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate" scope="prototype">
- <constructor-arg index="0" ref="sqlSessionFactory"/>
- </bean>
- <aop:aspectj-autoproxy/>
- <aop:config>
- <aop:pointcut id="appService" expression="execution(* com.yc.education.service..*Service*.*(..))"/>
- <aop:advisor advice-ref="txAdvice" pointcut-ref="appService"/>
- </aop:config>
- <tx:advice id="txAdvice" transaction-manager="transactionManager">
- <tx:attributes>
- <tx:method name="select*" read-only="true"/>
- <tx:method name="find*" read-only="true"/>
- <tx:method name="get*" read-only="true"/>
- <tx:method name="*"/>
- </tx:attributes>
- </tx:advice>
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"/>
- </bean>
- <!-- ...............................这个配置文件专门配置定时任务........................... -->
- <!-- <!– 方式二:使用MethodInvokingJobDetailFactoryBean,任务类可以不实现Job接口,通过targetMethod指定调用方法–>-->
- <!-- <!– 定义目标bean和bean中的方法 –>-->
- <bean id="SpringQtzJob" class="com.yc.education.controller.SupplierController"/>
- <bean id="SpringQtzJobMethod" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <property name="targetObject">
- <ref bean="SpringQtzJob"/>
- </property>
- <property name="targetMethod">
- <value>execute</value>
- </property>
- </bean>
- <!-- ======================== 调度触发器 ======================== -->
- <bean id="CronTriggerBean" class="org.springframework.scheduling.quartz.CronTriggerBean">
- <property name="jobDetail" ref="SpringQtzJobMethod"></property>
- <property name="cronExpression" value="0 0 0 * * ? *"></property>
- <!-- <property name="cronExpression" value="0 0 17 * * ? *"></property>-->
- </bean>
- <!-- ======================== 调度工厂 ======================== -->
- <bean id="SpringJobSchedulerFactoryBean" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <ref bean="CronTriggerBean"/>
- </list>
- </property>
- </bean>
- </beans>
|