rsi*_*va4 5 java groovy spring spring-el spring-boot
我创建了一个像这样的抽象类:
abstract class ScheduledProcess {
abstract List<String> fetchNewContent()
abstract List<String> cron()
//This SPeL doesn't work just stating what kind of expression I'm looking for
@Scheduled(cron='#{this.cron()}')
void persistContent(){
doSomeStuffWithContent(fetchNewContent())
}
}
Run Code Online (Sandbox Code Playgroud)
我的目标是不要重复自己必须@Scheduled
在所有子类中实现该方法。该cron()
方法返回特定子类的 cron 表达式。但是我没有找到将 cron 值传递给注释的方法。也许我只是以错误的方式看待这个问题。
我认为现在这是可能的(Spring 4.3.0),你可以在问题中看到它。
https://jira.spring.io/browse/SPR-13625
如果您使用其他 Spring 版本,您可以编写自己的 beanpostprocessor。您可以在此处看到量子给出的答案中的示例
归档时间: |
|
查看次数: |
2633 次 |
最近记录: |