There are many ways to configure a spring application. like XML based configuration.
JAVA Configuration is the most currently used spring configuration, because of various benefits it provides like-
- Native language syntax
- compile time checking of configuration.
- easier IDE integration.
Annotating a class with @Configuration indicates that the class can be used by the Spring IoC container as a source of bean definition.
@Bean annotation tells spring that a method annotated with @Bean annotation should be registered as a bean in the application context.
e.g.
@Configuration public class HelloWorldConfig { @Bean public HelloWorld helloWorld(){ return new HelloWorld(); } }
@Bean annotation tells the spring that the method will return an object that should be registered as a bean in Spring Application Context
No comments:
Post a Comment