【问题标题】:Spring scheduler tasks: read configuration on running timeSpring调度程序任务:在运行时读取配置
【发布时间】:2013-06-15 17:05:40
【问题描述】:

我正在使用 spring 3.0.7 和一些预定的作业:

public class TestScheduler implements Runnable{

private String someValue;

public void setSomeValue(String someValue) {
        this.someValue= someValue;
    }

@Override
public void run(){
    LOGGER.info("Some value: " + this.someValue);
}

配置:

<property name="someValue" value="${config.someValue}"/>

${config.someValue} 在 config.properties 文件中定义。 我希望每次计划作业执行 run() 方法时都能读取此配置文件上的值,因此每次更改要打印的变量的值时都不必重新启动服务器.

有什么程序可以做吗?我一直在阅读有关 @BeforeJob 注释的信息,但我不知道如何将其应用于计划作业,因为 documentation I read 是基于 JobExecution 的。

提前致谢

【问题讨论】:

    标签: spring scheduled-tasks


    【解决方案1】:

    我将使用这种方法: http://static.springsource.org/spring/docs/3.0.x/spring-framework-reference/html/dynamic-language.html

    所以我可以拥有我的配置文件,更改它并自动捕获它们。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-16
      • 1970-01-01
      • 2013-11-27
      • 2019-02-15
      • 2022-08-04
      • 1970-01-01
      • 2014-06-06
      • 2017-11-23
      相关资源
      最近更新 更多