Mel*_*ius 3 java spring inject
我有一个调度程序来清理数据库
@Scheduled(fixedDelay = @Value("#{new Long('${clean_up.period}')}"))
public void cleanStatInfoTable() {
List<StateInfo> infoLis=stateInfoRepository.findAllByCreatedDateBefore(LocalDateTime.now().minusHours(1));
stateInfoRepository.deleteInBatch(infoLis);
}
Run Code Online (Sandbox Code Playgroud)
但它会产生编译错误
不兼容的类型。找到:'org.springframework.beans.factory.annotation.Value',必需:'long'
我也尝试了表格, @Scheduled(fixedDelay = @Value("${obi.payments.state_info.clean_up.period}"))
但仍然是同样的问题
如何将long值注入到注释fixedDelay中的属性中Scheduled?
用fixedDelayString你现在拥有的代替。你让事情变得过于复杂。
@Scheduled(fixedDelayString = "${clean_up.period}"))
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
1948 次 |
| 最近记录: |