The web application context configuration file (WebApplicationContextConfig.java
) is nothing but a simple Java-based Spring bean configuration class. Spring will create beans (objects) for every bean definition mentioned in this class during the boot up of our application. If you open this web application context configuration file, you will find the following annotations on top of the class definition:
@Configuration
: This indicates that a class declares one or more@Bean
methods@EnableWebMvc
: Adding this annotation to an@Configuration
class imports some special Spring MVC configuration@ComponentScan
: This specifies the base packages to scan for annotated components (beans)
The first annotation @Configuration
indicates that this class declares one or more @Bean
methods. If you remember, in the last section, I explained how we created a bean definition for InternalResourceViewResolver
.
The second annotation is @EnableWebMvc
. With this...