添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
相关文章推荐
阳刚的骆驼  ·  AV Board Pro ...·  1 周前    · 
机灵的鸡蛋面  ·  docker部署 | OpenIM Docs·  1 月前    · 
开朗的海豚  ·  Utilise JSDoc comment ...·  2 月前    · 

java:S4605

I’m using SonarQube server 9.9 running SonarJava 7.16 and I’m getting the following issue on a Spring’s @Service annotated class:

‘MyClass’ is not reachable by @ComponentScan or @SpringBootApplication . Either move it to a package configured in @ComponentScan or update your @ComponentScan configuration.

I believe it’s a false positive because the beans are actually accessible in the application context of the service accessing this class.

This is the @AutoConfiguration class:

package com.org.myapp.config;
@AutoConfiguration
@ComponentScan(
    basePackageClasses = BaseScanningPackage.class,
    excludeFilters = {
        @ComponentScan.Filter(type = FilterType.ANNOTATION, classes = Configuration.class),
public class MyAppAutoConfig

And this is BaseScanningPackage:

package com.org.myapp;
public interface BaseScanningPackage
              

Hello @davoaux,

Thanks for reaching out and reporting the issue. Indeed the rule is quite old and does not take into consideration basePackageClasses.

I create a ticket for it:

https://sonarsource.atlassian.net/browse/SONARJAVA-4967

Best,
Margarita