gpt4 book ai didi

java - 不兼容的类型。找到 : 'org.springframework.beans.factory.annotation.Value' , 需要: 'long'

转载 作者:行者123 更新时间:2023-12-02 00:08:51 26 4
gpt4 key购买 nike

我有一个清理数据库的调度程序

@Scheduled(fixedDelay = @Value("#{new Long('${clean_up.period}')}"))
public void cleanStatInfoTable() {
List<StateInfo> infoLis=stateInfoRepository.findAllByCreatedDateBefore(LocalDateTime.now().minusHours(1));
stateInfoRepository.deleteInBatch(infoLis);
}

但是会产生编译错误

Incompatible types. Found: 'org.springframework.beans.factory.annotation.Value', required: 'long'

我还尝试了 @Scheduled(fixedDelay = @Value("${obi.payments.state_info.clean_up.period}")) 的形式但还是一样的问题

如何将 long 值注入(inject) Scheduled 注释中的 fixedDelay 属性?

最佳答案

使用 fixedDelayString 代替您现在拥有的。你让事情变得过于复杂。

@Scheduled(fixedDelayString = "${clean_up.period}"))

关于java - 不兼容的类型。找到 : 'org.springframework.beans.factory.annotation.Value' , 需要: 'long',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/59713189/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com