Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/314.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/spring/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 春天石英:工作不会被解雇_Java_Spring_Quartz Scheduler - Fatal编程技术网

Java 春天石英:工作不会被解雇

Java 春天石英:工作不会被解雇,java,spring,quartz-scheduler,Java,Spring,Quartz Scheduler,我使用的是石英2和弹簧3.0 我想使用SchedulerFactoryBean,但我的工作没有被解雇 下面是我的XML文件 <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://w

我使用的是石英2和弹簧3.0

我想使用SchedulerFactoryBean,但我的工作没有被解雇

下面是我的XML文件

<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">

    <bean id="quartzScheduler"
        class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
        <property name="autoStartup" value="true"/>
        <property name="schedulerName" value="PCLoaderScheduler"/>
    </bean>

</beans>
我知道当服务器启动时,调度程序正在启动。但它不能运行我的工作

另外,如果我使用下面的语句而不是自动连接SpringQuartz调度程序,那么该作业将被成功触发

scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();

请让我知道我做错了什么…

您需要在作业中注入依赖项吗?然后实施

并重写executeInternal()方法


另外,请检查在执行作业时是否出现异常。

首先,继续并将类似的内容添加到配置xml文件中。请注意如何更改repeatInterval和startDelay属性。或者,也可以使用cron表达式。从中了解他们


您可以找到我不久前写的原始文章。

Quartz 2和Spring 3.0不兼容。将Spring更新为3.1。现在它工作得很好

不,它不工作了。另外,我还记得“工作”曾经很有效。但我犯了一些小错误。不知道是什么。嗨,你找到解决办法了吗?谢谢你提供答案的建议。我在答案中包括了关键部分。
public class LoaderJob implements Job {

    public void execute(JobExecutionContext jec) throws JobExecutionException {
        System.out.println("Do your stuff here...");
    }

}
scheduler = new StdSchedulerFactory().getScheduler();
scheduler.start();
   <bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
      <property name="triggers">
         <list>             
            <ref bean="cronTrgTest" />
         </list>
      </property>
   </bean>

    <bean id="cronTrgTest" class="org.springframework.scheduling.quartz.SimpleTriggerBean">
        <property name="jobDetail" ref="testJob" />
        <property name="repeatInterval" value="5000" />
        <property name="startDelay" value="1000" />
    </bean>   

   <bean id="testJob" class="org.springframework.scheduling.quartz.MethodInvokingJobDetailFactoryBean">
      <property name="targetObject" ref="cronTest" />
      <property name="targetMethod" value="test" />
   </bean>   

   <bean id="cronTest" class="com.mustafaergin.ws.cron.CronTest">
   </bean>
public class CronTest {

    public void test() {
        System.out.println("TEST");
    }

}