@Bean、@Component、@Controller、@Service、@Repository
@Configuration 配置类
@Configuration(proxyBeanMethods = false)
参数:
proxyBeanMethods:代理bean的方法 默认true
true:在该类中所有注入到容器中的类都是单实例(Full模式)
false:非单实例(Lite模式)
组件依赖(一个组件调用另一个组件)必须使用Full模式默认。
@Import({XXX.class, XXXXX.class})
给容器中自动创建出多个类型的组件、默认组件的名字就是全类名
@ImportResource(“classpath:beans.xml”)
导入spring的配置文件来进行生效
@Conditional
条件装配:满足Conditional指定的条件,则进行组件注入
@ConditionalOnBean(name = "dem")//如果容器中包含dem组件则进行注入
@ConditionalOnMissingBean(name = "dem")//如果容器中不包含dem组件则进行注入
...