1、java配置方式 @Bean(initMethod="") 2、@PostConstruct和@PreDestroy标注在方法上 3、实现InitializingBean接口重写其afterPropertiesSet方法,实现DisposableBean接口重写destroy方法