為什么在類中定義幾個(gè)@Bean注解,同時(shí)指定initMethod和destroyMethod時(shí),在測(cè)試時(shí)會(huì)帶有其他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);
}
}
2016-10-16
有指定initMethod和destroyMethod時(shí),再帶有其他的初始化方法時(shí),默認(rèn)的不會(huì)生效??赡躼ml中配置了全局的方法了。