Spring的@configuration和@Bean

概要

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.

@Configuration意味着这个被注解的类可以被Spring IoC container(Spring IoC 容器)作为一个bean定义的来源,就是在启动时,让容器去扫描这里,加载底下的对象。

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.

@Bean意味着被它注解的方法将会返回一个对象,可以被作为bean注册在Spring application的context中。

参考

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