Spring 版本:2.0.7 与石英集成?

发布于 2024-11-08 02:01:21 字数 1477 浏览 1 评论 0原文

我正在使用 Spring 版本:2.0.7,我需要下载quartz 库及其依赖项才能使用它吗?因为一开始我虽然需要它,但它给了我一个 java.lang.InknownClassChangeError 。

所以我想它可能集成在 spring.jar 中,因为根据 2.5 spring,bean 是通过 spring 库在应用程序上下文上调用的。

然而,当我删除 quarta.jar 时,我无法访问 JobExecutionContext 类。这是我的 bean 声明:

<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass" value="com.bamboo.common.util.CheckAndProcessFilesJob" />
    <property name="jobDataAsMap">
    <map>
      <entry key="timeout" value="5" />
    </map>
    </property>
</bean>

java 代码

package com.bamboo.common.util;

import org.springframework.scheduling.quartz.QuartzJobBean;


    /**
     * Created by IntelliJ IDEA.
     * User: ernestobuttolazio
     * Date: 19-may-2011
     * Time: 16:44:54
     * To change this template use File | Settings | File Templates.
     */
    public class CheckAndProcessFilesJob extends QuartzJobBean {
        private int timeout;

        private int contador;
         /**
       * Setter called after the ExampleJob is instantiated
       * with the value from the JobDetailBean (5)
       */
      public void setTimeout(int timeout) {
        this.timeout = timeout;
      }

     protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
          // do the actual work
         contador += timeout;
      }

    }

i'm using Spring-Version: 2.0.7, do i need to download quartz libraries and their dependencies to use it ? cause at first i though it was needed but its giving me an java.lang.IncompatibleClassChangeError.

So i figured that maybe it was integrated in the spring.jar since according to the 2.5 spring the bean is invoked on the application context trhough the spring library.

How ever when i removed quarta.jar, i can´t acces the JobExecutionContext class. Here is my bean declaration:

<bean name="exampleJob" class="org.springframework.scheduling.quartz.JobDetailBean">
        <property name="jobClass" value="com.bamboo.common.util.CheckAndProcessFilesJob" />
    <property name="jobDataAsMap">
    <map>
      <entry key="timeout" value="5" />
    </map>
    </property>
</bean>

The java code

package com.bamboo.common.util;

import org.springframework.scheduling.quartz.QuartzJobBean;


    /**
     * Created by IntelliJ IDEA.
     * User: ernestobuttolazio
     * Date: 19-may-2011
     * Time: 16:44:54
     * To change this template use File | Settings | File Templates.
     */
    public class CheckAndProcessFilesJob extends QuartzJobBean {
        private int timeout;

        private int contador;
         /**
       * Setter called after the ExampleJob is instantiated
       * with the value from the JobDetailBean (5)
       */
      public void setTimeout(int timeout) {
        this.timeout = timeout;
      }

     protected void executeInternal(JobExecutionContext ctx) throws JobExecutionException {
          // do the actual work
         contador += timeout;
      }

    }

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

始终不够 2024-11-15 02:01:21

您需要使用石英2.1.6。应使用 JobDetailFactoryBean 代替 JobDetailBean。配置如下所示,

    <bean name="sampleJobDetail"
            class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
            <property name="jobClass"
                value="com.altisource.scheduler.jobs.SampleJob" />
            <property name="jobDataAsMap">
                <map>
                </map>
            </property>

        </bean>

        <bean id="sampleTrigger"
            class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
            <property name="jobDetail" ref="sampleJobDetail" />
            <property name="startDelay" value="30000" />
            <property name="repeatInterval" value="30000" />
            <property name="group" value="YOURCHOICE" />
        </bean>

如果您使用带有集群的quartz,则调度程序工厂 org.springframework.scheduling.quartz.SchedulerFactoryBean 将仅采用属性触发并限制提供jobDetails。确保仅使用触发器配置调度程序工厂org.springframework.scheduling.quartz.SchedulerFactoryBean

You need to use quartz 2.1.6. JobDetailFactoryBean should be used in place of JobDetailBean.The configuration will look like,

    <bean name="sampleJobDetail"
            class="org.springframework.scheduling.quartz.JobDetailFactoryBean">
            <property name="jobClass"
                value="com.altisource.scheduler.jobs.SampleJob" />
            <property name="jobDataAsMap">
                <map>
                </map>
            </property>

        </bean>

        <bean id="sampleTrigger"
            class="org.springframework.scheduling.quartz.SimpleTriggerFactoryBean">
            <property name="jobDetail" ref="sampleJobDetail" />
            <property name="startDelay" value="30000" />
            <property name="repeatInterval" value="30000" />
            <property name="group" value="YOURCHOICE" />
        </bean>

If your are using quartz with clustering, the scheduler factory org.springframework.scheduling.quartz.SchedulerFactoryBean will take only property triggers and restrict providing jobDetails. Make sure you configure scheduler factory org.springframework.scheduling.quartz.SchedulerFactoryBean with only triggers.

攒一口袋星星 2024-11-15 02:01:21

您需要将 Quartz 1.8.x 或更早版本与 Spring 当前的包装器一起使用。 Quartz 2.0 不适用于它们。

您可以将 Quartz 2.0 与 Spring 一起使用,没有问题 - 只是不能与 Spring 的包装器一起使用。

You need to use Quartz 1.8.x or earlier with Spring's current wrappers. Quartz 2.0 does not work with them.

You can use Quartz 2.0 along side Spring no problem - just not with Spring's wrappers.

暖阳 2024-11-15 02:01:21

Quartz 2.x 版本与 spring 不兼容。早期版本的一些类已转换为quartz 2.x 中的接口。但它仍然可以与 spring 一起使用,而不需要它的集成支持。
查看此链接 http://shyarmal.blogspot .com/2011/07/quartz-20-schedule-cron-with-spring.html

Quartz 2.x versions are not compatible with spring. Some classes of the earlier versions have been converted to interfaces in quartz 2.x. But still it can be used with spring, without the help of it's integration support.
Check out this link http://shyarmal.blogspot.com/2011/07/quartz-20-schedule-cron-with-spring.html.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文