[英]Using @ConfigurationProperties in a @Scheduled annotation by referencing the bean name
[英]Inject bean property in @Scheduled annotation
在我的課堂上,我有一個@Autowired
bean,它在其中一個@Autowired
中包含一個cron表達式。
在同一個類中,我有一個@Scheduled
方法,我希望將cron表達式設置為bean的屬性。
我已經嘗試了這個,它不起作用
@Scheduled(cron = "#{propertyBean.cronExpression}")
有任何想法嗎?
謝謝。
這個注釋對我有用:
@Scheduled(cron = "${property.with.cron}")
在我們的spring profile / application.properties中有這個:
property.with.cron=*/10 * * * * *
我們使用彈簧靴只是fyi
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.