【问题标题】:SonarQube Vulnerability - S3749 - Issue with @ConfigSonarQube 漏洞 - S3749 - @Config 问题
【发布时间】: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.
}

对于字段internalexternal,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


【解决方案1】:

从那里删除 @Component 它不属于那里只有 @ConfigurationProperties 会这样做。

【讨论】:

  • 感谢您的回复。我已经在cmets中提到了。
【解决方案2】:

成功了吗。从@Configurationproperty 文件中删除@Component

【讨论】:

猜你喜欢
  • 1970-01-01
  • 2021-06-05
  • 2022-01-17
  • 2018-10-12
  • 2017-05-12
  • 1970-01-01
  • 2011-03-07
  • 1970-01-01
  • 2021-12-21
相关资源
最近更新 更多