doCreateBean – initializeBean

doCreateBean - initializeBean

当spring完成属性注入之后, 就要开始 bean 的初始化了

代码片段:

org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory#doCreateBean

// Initialize the bean instance.
Object exposedObject = bean;
try {
    //设置属性,非常重要
    populateBean(beanName, mbd, instanceWrapper);
    //执行后置处理器,一部分aop就是在这里完成的处理
    exposedObject = initializeBean(beanName, exposedObject, mbd);
}
catch (Throwable ex) {
    if (ex instanceof BeanCreationException && beanName.equals(((BeanCreationException) ex).getBeanName())) {
        throw (BeanCreationException) ex;
    }
    else {
        throw new BeanCreationException(
                mbd.getResourceDescription(), beanName, "Initialization of bean failed", ex);
    }
}
hmoban主题是根据ripro二开的主题,极致后台体验,无插件,集成会员系统
自学咖网 » doCreateBean – initializeBean