springMVC配置定时器
2017-03-31 22:59
253 查看
1.web.xml文件中包含代码片:
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/applicationContext.xml,classpath*:config/spring-context-job.xml </param-value>
</context-param>
2.在spring-context-job.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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd"
default-lazy-init="false">
<beans>
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="weixinServiceTrigger"/>
</list>
</property>
</bean>
<bean id="weixinServiceTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="weixinServiceDetail"/>
<property name="startDelay" value="0" />
<property name="repeatInterval" value="500" />
</bean>
<bean id="userService" class="com.JunitTest1"></bean>
<bean id="weixinServiceDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="userService"/>
<property name="targetMethod" value="sys"/>
<property name="concurrent" value="false"/>
</bean>
</beans>
</beans>
3,写需要定时启动的方法
4,传五个jar包
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:config/applicationContext.xml,classpath*:config/spring-context-job.xml </param-value>
</context-param>
2.在spring-context-job.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:context="http://www.springframework.org/schema/context" xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xmlns:jee="http://www.springframework.org/schema/jee" xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.2.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-3.2.xsd"
default-lazy-init="false">
<beans>
<bean id="schedulerFactory" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
<property name="triggers">
<list>
<ref local="weixinServiceTrigger"/>
</list>
</property>
</bean>
<bean id="weixinServiceTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
<property name="jobDetail" ref="weixinServiceDetail"/>
<property name="startDelay" value="0" />
<property name="repeatInterval" value="500" />
</bean>
<bean id="userService" class="com.JunitTest1"></bean>
<bean id="weixinServiceDetail" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
<property name="targetObject" ref="userService"/>
<property name="targetMethod" value="sys"/>
<property name="concurrent" value="false"/>
</bean>
</beans>
</beans>
3,写需要定时启动的方法
4,传五个jar包
相关文章推荐
- springMVC中实现定时器可在Controller中配置定时器
- SpringMVC注解定时器的配置和时间设置
- SpringMVC的定时器(配置xml法)
- springmvc配置定时器
- springMVC定时器配置简单实例
- SpringMVC定时器配置
- dubbo2.5-spring4-mybastis3.2-springmvc4-mongodb3.4-redis3.2整合(十一)之 spring中定时器quartz的整合续集(Quartz集群配置)
- SpringMVC定时器配置文件说明
- STM32的学习心得之TIMx(通用定时器)基本的配置
- 实验十九、RIP-2 路由协议定时器配置
- java Spring定时器配置
- 报表制作工具定时器配置简要说明
- SpringMVC与Hibernate配置备忘
- spring中配置定时器
- springMVC 配置 说明
- 定时器介绍与Spring中定时器的配置
- 定时器介绍与Spring中定时器的配置(转)
- spring quartz配置定时器
- ARM7的定时器配置!
- 定时器在spring中的配置说明