云上的耳朵 2015-03-14 02:41 采纳率: 50%
浏览 16331

spring+quartz做的定时任务,tomcat启动没问题,就是定时任务不执行,是什么原因?

1.applicationContext_quartz.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:aop="http://www.springframework.org/schema/aop"
    xmlns:tx="http://www.springframework.org/schema/tx"
    xsi:schemaLocation="
    http://www.springframework.org/schema/beans 
    http://www.springframework.org/schema/beans/spring-beans.xsd
    http://www.springframework.org/schema/aop 
    http://www.springframework.org/schema/aop/spring-aop.xsd
    http://www.springframework.org/schema/tx 
    http://www.springframework.org/schema/tx/spring-tx.xsd">
    <!-- Spring定时任务 -->
    <!-- 定时任务 -->
    <bean id="quartzAction" class="com.test.action.QuartzTaskAction"/>
    <!-- 第一步:指定执行的类的方法名 -->
        <bean id="xhhf_jd" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
           <property name="targetObject"><ref bean="quartzAction"/></property>
           <property name="targetMethod"><value>xhhfDates</value></property>
        </bean>
    <!-- 第二步:指定触发的类型 -->
        <bean id="xhhf_ct" class="org.springframework.scheduling.quartz.CronTriggerBean">
           <property name="jobDetail"><ref bean="xhhf_jd" /></property>
           <property name="cronExpression" value="0/2 * * * * ?" /> 
        </bean>
    <!-- 第三步:开启定时任务 -->
    <bean id="startQuertz" class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="triggers">
           <list>
              <ref bean="xhhf_ct"/>
           </list>
       </property>
    </bean>
</beans>

2.QuartzTaskAction.action内容

 package com.test.action;

public class QuartzTaskAction{
    public void xhhfDates(){
        System.out.println("看我执行中。。。。");
    }
}

3web.xml配置内容

 <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>
            /WEB-INF/config/applicationContext_*.xml
        </param-value>
  </context-param>

4.tomcat启动日志

2015-3-14 10:21:11 org.apache.catalina.core.AprLifecycleListener init
信息: Loaded APR based Apache Tomcat Native library 1.1.30 using APR version 1.4.8.
2015-3-14 10:21:11 org.apache.catalina.core.AprLifecycleListener init
信息: APR capabilities: IPv6 [true], sendfile [true], accept filters [false], random [true].
2015-3-14 10:21:12 org.apache.catalina.core.AprLifecycleListener initializeSSL
信息: OpenSSL successfully initialized (OpenSSL 1.0.1g 7 Apr 2014)
2015-3-14 10:21:12 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["http-apr-80"]
2015-3-14 10:21:12 org.apache.coyote.AbstractProtocol init
信息: Initializing ProtocolHandler ["ajp-apr-8009"]
2015-3-14 10:21:12 org.apache.catalina.startup.Catalina load
信息: Initialization processed in 1196 ms
2015-3-14 10:21:12 org.apache.catalina.core.StandardService startInternal
信息: Starting service Catalina
2015-3-14 10:21:12 org.apache.catalina.core.StandardEngine startInternal
信息: Starting Servlet Engine: Apache Tomcat/7.0.54
2015-3-14 10:21:19 org.apache.tomcat.websocket.server.WsSci onStartup
信息: JSR 356 WebSocket (Java WebSocket 1.0) support is not available when running on Java 6. To suppress this message, run Tomcat on Java 7, remove the WebSocket JARs from $CATALINA_HOME/lib or add the WebSocket JARs to the tomcat.util.scan.DefaultJarScanner.jarsToSkip property in $CATALINA_BASE/conf/catalina.properties. Note that the deprecated Tomcat 7 WebSocket API will be available. 
2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log
信息: Set web app root system property: 'Heli' = [D:\Tomcat\webapps\Heli\]
2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log
信息: Initializing log4j from [D:\Tomcat\webapps\Heli\WEB-INF\log4j.properties]
2015-3-14 10:21:19 org.apache.catalina.core.ApplicationContext log
信息: Initializing Spring root WebApplicationContext
servlet初始化。。。。
2015-3-14 10:21:29 com.sun.faces.config.ConfigureListener contextInitialized
信息: 初始化上下文 '' 的 Mojarra 2.0.3 (FCS b03)
2015-3-14 10:21:30 com.sun.faces.spi.InjectionProviderFactory createInstance
信息: JSF1048:有 PostConstruct/PreDestroy 注释。标有这些注释的 ManagedBeans 方法将表示注释已处理。
2015-3-14 10:21:33 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["http-apr-80"]
2015-3-14 10:21:33 org.apache.coyote.AbstractProtocol start
信息: Starting ProtocolHandler ["ajp-apr-8009"]
2015-3-14 10:21:33 org.apache.catalina.startup.Catalina start
信息: Server startup in 21100 ms 

以上是全部内容,请问各位大神问题出在哪里了?急死了

  • 写回答

4条回答

  • yanhuhui 2015-03-17 06:16
    关注


    ...

    这里的class改用org.springframework.scheduling.quartz.CronTriggerFactoryBean试试

    评论

报告相同问题?

悬赏问题

  • ¥15 slam rangenet++配置
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制
  • ¥20 usb设备兼容性问题
  • ¥15 错误(10048): “调用exui内部功能”库命令的参数“参数4”不能接受空数据。怎么解决啊