The following example shows how to create a simple Java context configuration:
@Configuration class SpringContext { }
The key is the @Configuration annotation. This is what defines this as a Spring configuration.
One question remains; how does Spring IoC container know where to search for beans?
We need to tell the Spring IoC container the packages to search for by defining a component scan. Let's add a component scan to our earlier Java configuration definition:
@Configuration @ComponentScan(basePackages = { "com.mastering.spring" }) class SpringContext { }
We have defined a component scan for the com.mastering.spring package. It shows how all the classes we discussed until now are organized. ...