【发布时间】:2021-08-07 11:37:39
【问题描述】:
我将在@Scheduled 中动态设置“fixedRate”值。
为此,我尝试使用以下 SpEL 能力:
@AllArgsConstructor
public class ContentSender {
@Scheduled(fixedRateString = "#{OuterProperties.rateForMessageReading}")
public void contentModelMessageSource() throws IOException {
}
}
具有目标属性的类:
@Getter
@Setter
@ConfigurationProperties("app")
public class OuterProperties {
private static final long WAITING_INTERVAL = 100;
private long rateForMessageReading;
}
结果在我收到的部署阶段:
SpelEvaluationException: EL1008E: Property or field 'outerProperties' cannot be found on object of type 'org.springframework.beans.factory.config.BeanExpressionContext' - maybe not public or not valid?
我做错了什么?
【问题讨论】:
标签: java spring configuration spring-annotations