Annotation Name | Description |
---|---|
@EnableWebMvc | 1. if you used this annotation then it means you don't need web.xml, spring-context files etc. 2. your project is java based spring configuration. There is no need to have xml files. even you can have but that is not good a practice. 3. @EnableWebMvc is equivalent to <mvc:annotation-driven /> in XML. It enables support for @Controller -annotated classes that use @RequestMapping to map incoming requests to a certain method. |
@Configuration | 1. it is used to create java based spring bean configuration. 2. it removes the dependency on xml file where we create beans and decide the dependencies. 3. we mark java class with this annotation and each method would be marked as @Bean/@Secvice/@Component/@Repository and would be responsible for creating beans. |
@ComponentScan | This annotation is used to scan packages where we have defined our classes with @Bean, @Component, @Controller, @Service and @Repository annotations. 1. we can annotate our classes with @Component, @Controller, @Service and @Repository based on their behavior in different packages in java. Now we want to tell Spring to create/manage the object of these beans in the Spring Context. 2. we can provide multiple packages name in this annotation. For Example : @ComponentScan(basePackages = { "esant.controller", "esant.services", "esant.doa"}) |
@Import | 1. Lets suppose you have created 3 configuration files. a. SurveyConfig.java - this java file contains beans creation for survey crud operations. b. UserConfig.java - this java file contains beans creation for user crud operations. c. SurveyWebConfig.java - this is main config java file for our application contains other bean creation. 2. now this SurveyWebConfig class wants to import above 2 Config classes so that all the beans definition would be created by spring context. For Example: @Import({SurveyConfig.class, SurveyConfig.class}) |
@EnableWebSecurity | 1. There is some default security enabled by spring security configuration. like default password served by the spring-security. For example : Using default security password: c8be15de-4488-4490-9dc6-fab3f91435c6 2. if you want to write some custom security implementation extending WebSecurityConfigurerAdapter class then you would need to use @EnableWebSecurity. 3. it says you dont want to use default security features rather you want to use some customize configuration. https://www.baeldung.com/spring-boot-security-autoconfiguration https://www.baeldung.com/spring-security-login |
@RefreshScope | @RefreshScope annotation is used to load the configuration properties value from the Config server. |
@EnableAutoConfiguration |
0 comments :
Post a Comment