java - Sonar 的 Spring Boot 配置问题

标签 java spring-boot sonarqube

@ComponentsScan 或 @SpringBootApplication 无法访问“ABCService”。将其移动到 @ComponentsScan 中配置的包或更新您的 @ComponentsScan 配置。

这是我在 Sonarqube 分析中收到的 9 个严重错误的错误消息,每个服务和 Controller 都有一个。

尽管 @Autowire 和依赖注入(inject)工作正常,但 Sonar 似乎仍在提示。

导致问题的规则是:

Spring beans should be considered by "@ComponentScan"

Spring beans belonging to packages that are not included in a @ComponentScan configuration will not be accessible in the Spring Application Context. Therefore, it's likely to be a configuration mistake that will be detected by this rule. Note: the @ComponentScan is implicit in the @SpringBootApplication annotation, case in which Spring Boot will auto scan for components in the package containing the Spring Boot main class and its sub-packages.

由于@SpringBootApplication具有组件扫描功能,可以扫描主类包及其所有子包,因此这个问题不应该出现。

最佳答案

这是一个 SonarQube 错误,它无法正确处理 SpringBootApplication。您应该在这里报告:https://community.sonarsource.com/c/bug

关于java - Sonar 的 Spring Boot 配置问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57306616/

相关文章:

maven-3 - Sonar Pitest 插件

java - 直观理解

java - 如何使用 CrudRepository 中的 nativeQuery 以键、值的方式获取记录总和?

java - 如何部署java小程序进行本地开发

rest - Spring Boot REST - 公开与安全和不安全相同的服务

java - userDetailsS​​ervice org.springframework.beans.factory.UnsatisfiedDependencyException 错误

java - @ResponseBody 返回空对象

jenkins - sonar.Qualitygate 在 Sonar Qube 5.3 中已弃用。还有什么选择呢?

c# - Sonar : Validate changes from a date

java - 调整框架大小后如何调整网格大小?