[英]Why I can use immediate evaluation ${bean.property} with writable property?
[英]refer on bean.property in @Scheduled by SpEL
我将在@Scheduled 中动态设置“fixedRate”值。
为此,我正在尝试使用 SpEL 能力,如下所示:
@AllArgsConstructor
public class ContentSender {
@Scheduled(fixedRateString = "#{OuterProperties.rateForMessageReading}")
public void contentModelMessageSource() throws IOException {
}
}
Class 与目标属性:
@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?
我究竟做错了什么?
问题是我只使用@ConfigurationProperties。 当我添加@Configuration 问题就消失了。
@Getter
@Setter
@Configuration
@ConfigurationProperties("app")
public class OuterProperties {
private static final long WAITING_INTERVAL = 100;
private long rateForMessageReading;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.