A Spring Boot application class is in the default package, so component scanning reads every class on the class path
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.
import org.springframework.boot.autoconfigure.SpringBootApplication; @SpringBootApplicationtx0 reports: scans every class on the class pathclass Application {} 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:
[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.