My @SpringBootApplication annotation is present in com.abc.def package.
According to this article , using @SpringBootApplication annotation is equivalent to using @Configuration, @EnableAutoConfiguration, and @ComponentScan with their default attributes :-
https://docs.spring.io/spring-boot/docs/2.0.x/reference/html/using-boot-using-springbootapplication-annotation.html
If i supply my own @ComponentScan, does it add new packages to the default value or completely override the default ?
@SpringBootApplication annotation can component scan classes from packages under Application class belong to . Also you can add @ComponentScan to scan classes not under package Application class belongs to.
@ComponentScan("external.pkg")
@SpringBootApplication
class MyApp{
}
The @SpringBootApplication annotation doesn't allow all the filter customizations supported by @ComponentScan. We observed in our application that spring boot was automatically loading a @Configuration class from a library outside the package hierarchy of the class annotated with @SpringBootApplication.
If you want more control, one idea is to omit the @SpringBootApplication annotation and just specify the individual annotations @Configuration, @EnableAutoConfiguration, and @ComponentScan with your desired customizations.
More information is available in Spring Boot's Documentation:
18. Using the @SpringBootApplication Annotation
Good luck
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With