Configruation类配置
@Configuration 表明一个类是配置类,应该包含Spring应用上下文中如何创建bean的细节。
@ComponentScan(basePackages = “com.habuma.soundsystem”,
excludeFilters = { @Filter(Configuration.class) })
@Import({xxx.class, yyy.class}) 引入其他配置类
@ImportResource(“classpath:xxyy.xml”) 引入其他xml配置文件
@Profile(“dev”) 可以注解在类上或者方法上,用来表明某一配置类下所有Bean,或者某一个Bean要在具体的Profile下才能被激活。
激活具体的profile需要设置spring.profiles.default或者spring.profiles.active
@PropertySource(“classpath:/com/xxx.properties”) 引入外部属性源
@Bean(name=”xxx”) 在上下文中装配一个Bean
Component类的注解
@Component(“name”)
两种自动装配
@Autowired 只有一种实现是使用
@Qualifier(“”) 通过名字来注入具体的实现
String型资源装配
@Value(“${datasource.url}”)
String url;
JUnit测试配置
@RunWith(SpringJUnit4ClassRunner.class)
@Conte