为什么在类中定义几个@Bean注解,同时指定initMethod和destroyMethod时,在测试时会带有其他Bean的初始和销毁方法
@Configuration
@ImportResource("classpath:spring-beanannotation.xml")
public class StoreConfig {
@Value(value="${jdbc.url}")
private String url;
@Value(value="${jdbc.username}")
private String username;
@Value(value="${jdbc.password}")
private String password;
@Bean(name="sugerStore")
public Store getSugerStore(){
return new SugerStore();
}
@Bean(name="robotStore",initMethod="init",destroyMethod="destory")
public Store getRobotStore(){
return new RobotStore();
}
@Bean(name="driverStore")
public Store getDriverStore(){
return new DriverStore(url, username, password);
}
}