- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Spring Boot 2.2.6 和 documentation说:
When the
@ConfigurationProperties
bean is registered using configuration property scanning or via@EnableConfigurationProperties
, the bean has a conventional name:<prefix>-<fqn>
, where<prefix>
is the environment key prefix specified in the@ConfigurationProperties
annotation and<fqn>
is the fully qualified name of the bean. If the annotation does not provide any prefix, only the fully qualified name of the bean is used.The bean name in the example above is acme-com.example.AcmeProperties.
但是当我使用这个 SpEL 时:@Scheduled(fixedDelayString = "#{@(mr-my.config.properties.ApplicationProperties).task.get(T(my.config.Constants).CONST).delay}")
我收到错误:
Parameter 0 of constructor in my.controllers.Controller required a bean named 'mr' that could not be found.
Action:
Consider defining a bean named 'mr' in your configuration.
最佳答案
提供给 ConfigurationProperties
注释的前缀是 bean 的名称。
例如:
package com.my.company;
...
@ConfigurationProperties("alpha.beta.gamma")
public class TheTimes {
private Duration theInterval = Duration.ofSeconds(30);
// getter and setter
}
然后
@Scheduled(fixedDelayString = "#{@'alpha.beta.gamma-com.my.company.TheTimes'.theInterval}")
关于java - 如何在 spring-boot 2.2.* 中将 @ConfigurationProperties bean Autowiring 到 SpEL 表达式中?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62449641/
我是一名优秀的程序员,十分优秀!