A Spring Boot application class is in the default package, so component scanning reads every class on the class path

tx0/java:spring-app-default-packagedefaulterrorbug

What it finds

@SpringBootApplication and @ComponentScan scan the package of their class and all packages below it. In the default package that is every class of every jar, which makes start-up slow or fails with conflicting beans, as the Spring Boot reference warns.

Reported is a class with one of these annotations in a file without a package declaration.

From the rule's source, spring_app_default_package.rs.

Example from the rule's tests
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplicationtx0 reports: scans every class on the class pathclass Application {}
Highlighted lines are the ones tx0 reports, with its message under each; the other lines are left alone.

Turn it on, off or suppress it

The rule runs in every tier. To turn it off for a project, set its level in tx0.toml:

tx0.toml
[rules]
"tx0/java:spring-app-default-package" = "off"

To keep one finding, suppress it with a reason. tx0 suppress ID --reason "..." writes the comment on the line before the code:

// tx0: ignore[tx0/java:spring-app-default-package] reason="..."

tx0 explain tx0/java:spring-app-default-package shows the same in the terminal. Found a false positive? Report it.