I want to create a new Spring Boot web application.
My structure should be the following:
com.base.package
MyApplication
config
domain
repository
service
web
I can go two ways:
- Annotate MyApplication with
@SpringBootApplication
and let it find controllers, JPA repositories etc. - Use
@EnableWebMvc
,@EnableJpaRepostories
and so on along with@ComponentScan(basePackages=...)
in order to point the base packeges for different component types explicitly.
I would happily go with the first approach but there is a concern that it will take more time to start the application then (if the app codebase grows significantly) because Spring would scan everything instead of particular packages. But it anyway should read all these files to find the beans at least once.
So the question is:
Is the Spring (Boot) smart enough to scan all subpackeges for the beans only once or it would add an overhead to leave it with the default configuration?