首页 > 编程知识 正文

afterpropertiesset,spring事务注解原理

时间:2023-05-04 01:28:31 阅读:133486 作者:4622

在查看redis异步消息队列的实现时,遇到了注册事件,其中看到了afterPropertiesSet。 然后查博客并记录。

一、简要介绍

1、init-method方法在初始化bean时执行,并可针对特定bean放置。 init-method必须在applicationContext.xml配置文档中的bean定义中注明。 testbean,例如bean id=' testbean ' class=' nju.software.xkxt.util.testbean ' init-method=' init '/bean afterPropertiesSet必须实现初始化bean接口。 要实现InitializingBean接口,必须实现afterPropertiesSet方法。 3、BeanPostProcessor。 可以在配置文档applicationContext.xml中为所有Spring上下文中的所有bean配置BeanPostProcessor,并对所有bean执行初始化前后代理。 BeanPostProcessor界面有两种方法: postprocessbeforeinitialization和postProcessAfterInitialization。 postprocessbeforeinitialization方法在bean初始化之前执行,postProcessAfterInitialization方法在bean初始化之后执行。 也就是说,afterPropertiesSet和init-method之间的执行顺序是先执行afterPropertiesSet,后执行init-method。 从BeanPostProcessor角色开始,首先运行postprocessbeforeinitialization,然后运行afterPropertiesSet,然后运行init-method,然后运行postprocesbeforeinitiation

版权声明:该文观点仅代表作者本人。处理文章:请发送邮件至 三1五14八八95#扣扣.com 举报,一经查实,本站将立刻删除。