Spring应用程序中Quartz Scheduler的加载太频繁 [英] Too frequent load of Quartz Scheduler in a Spring application

查看:199
本文介绍了Spring应用程序中Quartz Scheduler的加载太频繁的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在编写一个Spring应用程序,并且使用了Quart Scheduler。

I am writing a Spring application and I use Quart Scheduler.

我正在运行Jetty服务器,一切正常,我的应用程序可以运行:

I'm running Jetty server and everything is ok, my app works:

我正在向我的服务之一发送HTTP请求,然后,一切都刷新了:

I am sending an HTTP request to the one of my services and then, everything is refreshing:

,而Quartz给出此日志3次:

and Quartz gives this log 3 times:

这是我config.xml的一部分文件:

Here is a piece of my config.xml file:

<bean id="simpleTrigger" class="org.springframework.scheduling.quartz.SimpleTriggerBean">

    <property name="jobDetail" ref="fileimport" />
    <property name="repeatInterval" value="${prop.checkinterval}" />

</bean>

<bean class="org.springframework.scheduling.quartz.SchedulerFactoryBean">
    <property name="jobDetails">
        <list>
            <ref bean="fileimport" />
        </list>
    </property>

    <property name="triggers">
        <list>
            <ref bean="simpleTrigger" />
            </list>
    </property>
</bean>

如何在启动过程中加载一次上下文,然后在不刷新的情况下使用它?

How can I load context once, during startup, and use it later without refreshing?

推荐答案

您的问题是,每次加载XML文件时都会重新加载上下文。尝试为每个Java类创建不同的XML文件,然后仅将它们加载一次。

Your problem here is that the context is reload each time when you load your XML file. Try to create different XML files for each Java Class and then, load each of them just once.

您可以在班级的私有静态字段中使用它。

You can use it us a private static field of your class.

这篇关于Spring应用程序中Quartz Scheduler的加载太频繁的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆