Spring beans should be considered by “@ComponentScan

I am using

  • SonarQube Enterprise Edition Version 9.2.4 (build 50792)
  • Scanner:
  • SonarLint for IntelliJ 6.7.0.45926
  • sonar-maven-plugin:3.9.1.2184

I have a Spring Boot application and the scanner produces the warning “Spring beans should be considered by “@ComponentScan”” for the following class:

package com.company.a.b.c.impl;

@Service
public class MyService {...}

Then the Application class:

package com.company.a

@SpringBootApplication
public class MyApplication {...}

I am aware of this answer False positive for Spring java:S4605 for multi-module projects. "component is not visible by @ComponentScan"

and since my project is a multi-module project, I also tried adding an empty @Component annotation and also a @Component with different values, once “com.company.a.b”, once “com.company.a.b.c.impl” but SonarLint still displays the warning.

Please note that the application is started as expected.

Hi,

Welcome to the community!

To be clear, you’re reporting a false positive?

 
Ann

Thanks :slight_smile:
Yes, since my application is working as expected I believe that this is a false positive.

1 Like

Hey @cbertoldi_p,

Thanks for reporting the issue. As you noted, there are known limitations to that rule and the Java analyzer but if you are seeing the issue in SonarLint, then there might be something else going on.

Just to clarify: are you running SonarLint in connected mode? (assuming connected to Sonarlcoud here)

Hey Dorian_Burihabwa, yes, I am running SonarLint in connected mode.