@Scope:设置bean的作用范围
@PostConstruct:设置bean的初始化方法
@PreDestroy:设置bean的销毁方法
@Repository
@Scope("singleton")
public class BookDaoImpl implements 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 ...");
}
}