June 2018
Intermediate to advanced
408 pages
11h 23m
English
Spring needs to know which packages contain Spring beans, otherwise, you would have to register each bean individually. That's what @ComponentScan is used for. In Spring, component scanning is not enabled by default. We need to enable it with the @ComponentScan annotation. This annotation is used with the @Configuration annotation to allow Spring to know the packages to scan for annotated components and to create beans from them. Let's look at the following simple example of @ComponentScan:
@Configuration@ComponentScan(basePackages="com.packt.springhighperformance.ch2.bankingapp.model")public class AppConfig {}
In the @ComponentScan annotation, if the basePackages attribute is not defined, then scanning will ...
Read now
Unlock full access