123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198 |
- <?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:context="http://www.springframework.org/schema/context"
- xmlns:jdbc="http://www.springframework.org/schema/jdbc"
- xmlns:tx="http://www.springframework.org/schema/tx"
- xmlns:mvc="http://www.springframework.org/schema/mvc"
- xsi:schemaLocation="http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc-4.2.xsd
- http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.2.xsd
- http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.2.xsd
- http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.2.xsd"
- default-lazy-init="true" >
- <!--<context:component-scan base-package="cn.ourwill" >-->
- <!--<context:include-filter type="annotation" expression="org.springframework.stereotype.Controller"/>-->
- <!--<context:include-filter type="annotation" expression="org.springframework.web.bind.annotation.ControllerAdvice"/>-->
- <!--</context:component-scan>-->
- <context:component-scan base-package="cn.ourwill">
- <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller"/>
- </context:component-scan>
- <!-- 配置文件加载 -->
- <bean id="propertyConfigurer"
- class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
- <property name="locations">
- <list>
- <value>classpath:/project.properties</value>
- </list>
- </property>
- </bean>
- <bean id="dataSource" class="com.alibaba.druid.pool.DruidDataSource" init-method="init" destroy-method="close">
- <property name="driverClassName" value="com.mysql.jdbc.Driver"/>
- <property name="url" value="${jdbc.url}"/>
- <property name="username" value="${jdbc.username}"/>
- <property name="password" value="${jdbc.password}"/>
- <!-- 配置初始化大小、最小、最大 -->
- <property name="initialSize" value="${jdbc.initialPoolSize}" />
- <property name="minIdle" value="${jdbc.minPoolSize}" />
- <property name="maxActive" value="${jdbc.maxPoolSize}" />
- <!-- 配置获取连接等待超时的时间 -->
- <property name="maxWait" value="60000" />
- <!-- 配置间隔多久才进行一次检测,检测需要关闭的空闲连接,单位是毫秒 -->
- <property name="timeBetweenEvictionRunsMillis" value="60000" />
- <!-- 配置一个连接在池中最小生存的时间,单位是毫秒 -->
- <property name="minEvictableIdleTimeMillis" value="300000" />
- <property name="validationQuery" value="SELECT 'x'" />
- <property name="testWhileIdle" value="true" />
- <property name="testOnBorrow" value="false" />
- <property name="testOnReturn" value="false" />
- <!-- 打开PSCache,并且指定每个连接上PSCache的大小 -->
- <!-- <property name="poolPreparedStatements" value="false" /> -->
- <!-- <property name="maxPoolPreparedStatementPerConnectionSize" value="20" /> -->
- <!-- 配置监控统计拦截的filters -->
- <property name="filters" value="stat" />
- </bean>
-
- <bean id="transactionManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
- <property name="dataSource" ref="dataSource"></property>
- </bean>
- <tx:annotation-driven transaction-manager="transactionManager" proxy-target-class="true"/>
-
- <!-- 扫描basePackage下所有以@MyBatisDao注解的接口 -->
- <bean id="mapperScannerConfigurer" class="org.mybatis.spring.mapper.MapperScannerConfigurer">
- <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory" />
- <property name="basePackage" value="cn.ourwill"/>
- <property name="annotationClass" value="cn.ourwill.core.dao.MyBatisDao"/>
- </bean>
-
-
- <!-- 本项目数据源代码-->
- <bean id="sqlSessionFactory" class="org.mybatis.spring.SqlSessionFactoryBean">
- <property name="dataSource" ref="dataSource" />
- <!-- 显式指定Mapper文件位置 -->
- <property name="configLocation" value="classpath:/mybatis-config.xml"/>
- <!-- 通配符指定Mapper.xml -->
- <property name="mapperLocations" value="classpath:/mappings/modules/**/*Dao.xml" />
- <!-- 自动扫描entity目录, 省掉Configuration.xml里的手工配置 -->
- <property name="typeAliasesPackage" value="cn.ourwill" />
- <property name="typeAliasesSuperType" value="cn.ourwill.core.entity.BaseEntity"/>
- <property name="plugins">
- <array>
- <bean class="com.github.pagehelper.PageInterceptor">
- <property name="properties">
- <value>
- <!--使用默认配置即可 -->
- </value>
- </property>
- </bean>
- </array>
- </property>
- </bean>
-
- <bean id="sqlSessionMain" class="org.mybatis.spring.SqlSessionTemplate">
- <constructor-arg index="0" ref="sqlSessionFactory"/>
- </bean>
- <bean id="mybatisDao" class="cn.ourwill.module.house.dao.daily.MybatisDao">
- <property name="sqlSession" ref="sqlSessionFactory" />
- </bean>
- <!--要调用的工作类 -->
- <!--
- <bean id="quartzJob" class="cn.ourwill.core.quartz.QuartzJob" ></bean>
- <bean id="quartzJobLogin" class="cn.ourwill.core.quartz.QuartzJobLogin"></bean>
- <!–定义调用对象和调用对象的方法–>
- <bean id="jobtask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <!–调用的类–>
- <property name="targetObject">
- <ref bean="quartzJob"/>
- </property>
- <!–调用类中的方法–>
- <property name="targetMethod">
- <value>work</value>
- </property>
- </bean>
- <bean id="dayTask" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <!–调用的类–>
- <property name="targetObject">
- <ref bean="quartzJob"/>
- </property>
- <!–调用类中的方法–>
- <property name="targetMethod">
- <value>dayTask</value>
- </property>
- </bean>
- <bean id="jobtasklogin" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
- <!– 调用的类 –>
- <property name="targetObject">
- <ref bean="quartzJobLogin" />
- </property>
- <!– 调用类中的方法 –>
- <property name="targetMethod">
- <value>quartzMethodLogin</value>
- </property>
- <!– 是否允许任务并发执行。当值为false时,表示必须等到前一个线程处理完毕后才再启一个新的线程 –>
- <!–<property name="concurrent" value="false"/>–>
- </bean>
- <!–定义触发时间 2.x.x版本之后CronTriggerFactoryBean–>
- <bean id="doTime" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
- <property name="jobDetail">
- <ref bean="jobtask"/>
- </property>
- <!–cron表达式 –>
- <property name="cronExpression">
- <value>0 0 0/1 * * ?</value>
- <!–每天0点到23点,每整点执行一次:0 0 0-23 * * ?
- 每个整点执行一次:0 0 0/1 * * ? –>
- </property>
- </bean>
- <bean id="dayTime" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
- <property name="jobDetail">
- <ref bean="dayTask"/>
- </property>
- <!–cron表达式 –>
- <property name="cronExpression">
- <!–<value>0 50 23 * * ?</value>–>
- <value>0 20 23 ? * *</value><!–每个月最后一天23:59:50执行一次–>
- </property>
- </bean>
- <bean id="doTimeLogin" class="org.springframework.scheduling.quartz.CronTriggerFactoryBean">
- <property name="jobDetail">
- <ref bean="jobtasklogin"/>
- </property>
- <!–cron表达式 –>
- <property name="cronExpression">
- <value>0 30 0 * * ?</value>
- </property>
- </bean>
- <!–总管理类 如果将lazy-init='false'那么容器启动就会执行调度程序–>
- <bean id="startQuertz" lazy-init="false" autowire="no" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
- <property name="triggers">
- <list>
- <!–<ref bean="dayTime"/>
- <ref bean="doTime"/>
- <ref bean="doTimeLogin"/>–>
- </list>
- </property>
- </bean>
- -->
- <bean class="tk.mybatis.spring.mapper.MapperScannerConfigurer">
- <!-- 为映射器接口文件设置基本的包路径 -->
- <property name="basePackage" value="cn.ourwill.module.house.dao.new_dao" />
- </bean>
- </beans>
|