简体   繁体   English

BeanPostProcessor的示例

[英]Example of BeanPostProcessor

I know how spring BeanPostProcessor works but I exactly don't get any such scenarios where BeanPostProcessor might be very helpful. 我知道spring BeanPostProcessor工作原理,但是我完全没有得到BeanPostProcessor可能会非常有用的这种方案。 If someone has implemented BeanPostProcessor in his/her application, then please give a brief about that. 如果有人在他/她的应用程序中实现了BeanPostProcessor ,请对此做一个简要介绍。

The BeanPostProcessor interface is arguably the most basic and useful tool of the Spring IoC container. BeanPostProcessor接口可以说是Spring IoC容器中最基本,最有用的工具。 Take a look at the implementing classes in the javadoc. 看一看javadoc中的实现类。

You typically use Spring to inject beans into other beans. 通常,您可以使用Spring将bean注入其他bean。 Spring uses AutowiredAnnotationBeanPostProcessor to achieve this. Spring使用AutowiredAnnotationBeanPostProcessor来实现这一点。 After the bean has been instantiated, this BeanPostProcessor scan the bean's fields for @Autowired targets. 实例化bean之后,此BeanPostProcessor扫描bean的字段中的@Autowired目标。 If it finds any, it tries to resolve a bean from the context to inject. 如果找到任何内容,它将尝试从上下文中解析要注入的bean。 You can find the source code here . 您可以在此处找到源代码。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM