【发布时间】:2020-06-17 07:45:54
【问题描述】:
Given 是 @ConfigurationProperties 的场景,其中内部和外部定义为 -
consumers:
internal = some value
external = other value
并映射到下面的类 -
@Component
@ConfigurationProperties(prefix = "consumers")
public class ConsumerConfig {
private String internal;
private String external;
... getter and settter.
}
对于字段internal 和external,SonarQube 扫描对规则S3749 给出错误 -
Annotate this member with "@Autowired", "@Resource", "@Inject", or "@Value", or remove it
如何解决这个问题。这个场景对于@Controller @Service 和 Other 类注解看起来是有效的,但是这在这种情况下是如何应用的。
我正在使用 Spring Boot 2.1.8.RELEASE
【问题讨论】:
-
错了,不应该用
@Component代替@ConfigurationProperties
标签: java spring-boot sonarqube