第一种:
实现InitializingBean接口,重写afterPropertiesSet()方法。
第二种:
属性配置文件init-method指定。
同理还有销毁方式,所不同的是:
需要实现DisposableBean中的destroy()方法。
第二种
destroy-method指定。