Spring的@configuration和@Bean

博客

原帖位于IT老兵博客

正文

总结整理一下spring的@configuration和@Bean。

Annotating a class with the @Configuration indicates that the class can be used by the Spring IoC container as a source of bean definitions. The @Bean annotation tells Spring that a method annotated with @Bean will return an object that should be registered as a bean in the Spring application context.

@Configuration意味着一个类可以被Spring IoC container作为一个bean的定义。
@Bean意味着被它注解的方法将会返回一个对象,可以被作为bean注册。

参考

https://www.tutorialspoint.com/spring/spring_java_based_configuration.htm

猜你喜欢

转载自blog.csdn.net/chaiyu2002/article/details/87371233