(1) 通过注解的方式 自动装配
@Component
和config 类
启用 @Configuration 和@ComponentScan(basePackageClasses={a.class,b.class})
(2) java config
不启用@ ComponentScan
只用@Configuration 结合@Bean(name=”xx”) 显式声明,bean
(3) XML 声明 bean
(4) 混合声明 javaconfig 引入xml
@ImportResource(“classpath: aaa.xml”)
xml引入javaconfig
<bean class="com.xx.AaConfig">