InitializingBean 接口作用

来源:互联网 发布:php msgpack unpack 编辑:程序博客网 时间:2024/06/07 07:03
public interface InitializingBean {
    
    /**
     * Invoked by a BeanFactory after it has set all bean properties supplied
     * (and satisfied BeanFactoryAware and ApplicationContextAware).
     * <p>This method allows the bean instance to perform initialization only
     * possible when all bean properties have been set and to throw an
     * exception in the event of misconfiguration.
     * @throws Exception in the event of misconfiguration (such
     * as failure to set an essential property) or if initialization fails.
     */
    void afterPropertiesSet() throws Exception;

}


实现此接口的类,在数据注入完成后,将执行afterPropertiesSet()方法,因此我们可以再这个方法中执行一些校验工作