<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:util="http://www.springframework.org/schema/util" xmlns:p="http://www.springframework.org/schema/p"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:task="http://www.springframework.org/schema/task" xmlns:aop="http://www.springframework.org/schema/aop"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-4.1.xsd
http://www.springframework.org/schema/util
http://www.springframework.org/schema/util/spring-util-4.1.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-4.1.xsd
http://www.springframework.org/schema/task
http://www.springframework.org/schema/task/spring-task-4.1.xsd
http://www.springframework.org/schema/aop
http://www.springframework.org/schema/aop/spring-aop-4.1.xsd"
default-lazy-init="true">
<description>Spring公共配置 </description>
<!-- 打开@aspectj支持 -->
<aop:aspectj-autoproxy proxy-target-class="true" />
<!-- 配置注解运行机制 -->
<!-- <task:annotation-driven proxy-target-class="true"
executor="taskExecutor" scheduler="taskScheduler" /> -->
<!-- 运行的线程数配置 -->
<!-- <task:executor id="taskExecutor" pool-size="50" /> -->
<!-- 配置注解运行机制 -->
<task:annotation-driven proxy-target-class="true" executor="taskExecutor" scheduler="taskScheduler"/>
<!-- 运行的线程数配置 -->
<task:executor id="taskExecutor" pool-size="50"/>
<!-- 秘钥可明文指定,也可以设置成环境变量(把property的name设置为passwordEnvName),启动服务然后删除环境变量 -->
<bean id="environmentVariablesConfiguration" class="org.jasypt.encryption.pbe.config.EnvironmentStringPBEConfig">
<property name="algorithm" value="PBEWithMD5AndDES" />
<property name="password" value="root" />
</bean>
<bean id="configurationEncryptor" class="org.jasypt.encryption.pbe.StandardPBEStringEncryptor">
<property name="config" ref="environmentVariablesConfiguration" />
</bean>
<bean id="propertyConfigurer"
class="org.jasypt.spring31.properties.EncryptablePropertyPlaceholderConfigurer">
<constructor-arg ref="configurationEncryptor" />
<property name="locations">
<list>
<value>classpath:application.properties</value>
</list>
</property>
<property name="fileEncoding" value="utf-8" />
</bean>
<!-- 如果需要配置分布式作业,请查看配置http://git.oschina.net/uncode/uncode-schedule -->
<!-- spring作业运行机制 -->
<task:scheduler id="taskScheduler" pool-size="50" />
<import resource="classpath*:/spring-data-redis*.xml" />
<!-- <import resource="classpath*:/spring-mail*.xml" /> -->
<!-- <import resource="classpath*:/spring-activemq*.xml" /> -->
<!-- 服务器监控的开启 -->
<import resource="classpath*:/spring-javasimon.xml" />
<!-- 邮箱服务的开启 -->
<import resource="classpath*:/spring-mail*.xml" />
<!-- redis和方法缓存的应用 -->
<!-- <import resource="classpath*:/spring-cache.xml" /> -->
<!-- webservice的应用(不建议使用这个方式) -->
<!-- <import resource="classpath*:/spring-webservice*.xml" /> -->
<!--RPC方式的接口调用建议前端程序使用的调用方式 -->
<import resource="classpath*:/spring-dubbo*.xml" />
<!--hibernate数据库的配置 -->
<import resource="classpath*:/spring-hibernate.xml" />
<!--netty通讯的配置 -->
<!-- <import resource="classpath*:/spring-netty.xml" /> -->
<!--mybatis数据库的配置 -->
<import resource="classpath*:/spring-mybatis.xml" />
<!--mongodb数据库的配置 -->
<import resource="classpath*:/spring-mongodb.xml" />
<!-- solr 服务器的配置 -->
<import resource="classpath*:/spring-solr.xml" />
<!-- 定义受环境影响易变的变量 -->
<context:property-placeholder
ignore-resource-not-found="true" location="classpath*:/application.properties" />
<bean id="myPassWordEncoder"
class="org.springframework.security.crypto.password.StandardPasswordEncoder">
<constructor-arg index="0" value="${key}"></constructor-arg>
</bean>
<!-- 使用annotation 自动注册bean,并保证@Required,@Autowired的属性被注入 -->
<context:component-scan base-package="com.alqsoft">
<context:exclude-filter type="regex"
expression="com.alqsoft.controller.*" />
</context:component-scan>
<!-- 数据源配置,使用应用内的Tomcat JDBC连接池 -->
<!-- <bean id="dataSource1" class="com.alibaba.druid.pool.DruidDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url1}" />
<property name="filters" value="stat" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="${jdbc.pool.maxActive}" />
<property name="maxIdle" value="${jdbc.pool.maxIdle}" />
<property name="minIdle" value="0" />
<property name="defaultAutoCommit" value="false" />
<property name="timeBetweenEvictionRunsMillis" value="360000" />
<property name="minEvictableIdleTimeMillis" value="3600000" />
</bean> -->
<bean id="dataSource" class="com.zc.dds.pool.DdsDataSource"
destroy-method="close">
<property name="driverClassName" value="com.mysql.jdbc.Driver" />
<property name="url" value="${jdbc.url1}"/>
<property name="username" value="root" />
<property name="password" value="root" />
<property name="minIdle" value="5" />
<property name="initialSize" value="30" />
</bean>
<!-- <bean id="dataSource2" class="com.alibaba.druid.pool.DruidDataSource"
destroy-method="close">
<property name="driverClassName" value="${jdbc.driver}" />
<property name="url" value="${jdbc.url2}" />
<property name="filters" value="stat" />
<property name="username" value="${jdbc.username}" />
<property name="password" value="${jdbc.password}" />
<property name="maxActive" value="${jdbc.pool.maxActive}" />
<property name="maxIdle" value="${jdbc.pool.maxIdle}" />
<property name="minIdle" value="4" />
<property name="defaultAutoCommit" value="false" />
<property name="timeBetweenEvictionRunsMillis" value="360000" />
<property name="minEvictableIdleTimeMillis" value="3600000" />
</bean> -->
<!-- <bean id="dataSource2" class="com.zc.dds.pool.ConnectionPool"
destroy-method="close">
<property name="jdbcDriver" value="com.mysql.jdbc.Driver" />
<property name="dbUrl" value="${jdbc.url2}"/>
<property name="dbUsername" value="root" />
<property name="dbPassword" value="123456" />
</bean> -->
<!-- 数据源配置,使用应用服务器的数据库连接池 -->
<!--<jee:jndi-lookup id="dataSource" jndi-name="java:comp/env/jdbc/ExampleDB"
/> -->
</beans>
applicationContext.xml配置文件
java代码进行调度的时在配文件中需要配置
<!--配置注解运行机制,poxy-target-clas为true时使用的时动态代理-->
<task:
task:annotation-driven proxy-target-class="true" executor="taskExecutor" scheduler="taskScheduler"/> <!--运行的线程配置--> <task:executor id="taskExecutor" pool-size="50"/> <!--spring中的线程配置> <task:schedule id="taskSchedule" pool-size="50"/> 需要调度的java代码
java代码的具体分析:@Component @Lazy(value = false) public class OrderTask { @Autowired private OrderService orderService; /** * 十五天自动确认收货 */ @Scheduled(cron = "0/1 * * * * *") public void authConfirmReceive(){ orderService.autoConfirmReceive(); } /** * 七天自动分润 */ @Scheduled(cron = "0/1 * * * * *")//每秒执行 public void orderFenRun(){ this.orderService.orderFenRun(); } /** * 普惠分润 10分钟一次 */ @Scheduled(cron = "0 0/10 * * * *")//10分钟执行 public void orderPuhuiFenRun(){ this.orderService.orderPuhuiFenRun(); } }
@Scheduled(cron="")这是对应的调度时间
http://blog.csdn.net/a1124544556/article/details/53884997