解释AFTERPROPERTIESSET
在spring的bean的生命周期中,实例化->生成对象->属性填充后会进行afterPropertiesSet方法,这个方法可以用在一些特殊情况中,也就是某个对象的某个属性需要经过外界得到,比如说查询数据库等方式,这时候可以用到spring的该特性,只需要实现InitializingBean即可:
@Component("a")public class A implements InitializingBean {private B b;public A(B b) {this.b = b;}@Overridepublic void afterPropertiesSet() throws Exception {}}这样可以在afterPropertiesSet方法中进行你的额外操作。
Test comment for verification
Test comment for verification
Test comment for verification