Bean管理
Bean作用范围
使用@Scope("singleton")定义Bean作用范围
@Repository
@Scope("singleton")
public class BookDaoImpl implments BookDao{
public void save(){
System.out.println("book dao save ...");
}
@PostConstruct
public void init(){
System.out.println("init ...");
}
@PreDestroy
public void destroy(){
System.out.println("destroy ...");
}
}
Bean生命周期
使用@PostConstruct、@PreDestroy定义Bean生命周期