Spring拓展接口之BeanFactoryPostProcessor,占位符与敏感信息解密原理

    一只被二哈带偏了的柴犬,我只想弄死隔壁的二哈

Spring拓展接口之BeanFactoryPostProcessor,占位符与敏感信息解密原理

what:是什么

  BeanFactoryPostProcessor接口很简单,只包含一个方法

/** * 通过BeanFactoryPostProcessor,我们自定义修改应用程序上下文中的bean定义 * * 应用上下文能够在所有的bean定义中自动检测出BeanFactoryPostProcessor bean, * 并在任何其他bean创建之前应用这些BeanFactoryPostProcessor bean * * BeanFactoryPostProcessor对自定义配置文件非常有用,可以覆盖应用上下文已经配置了的bean属性 * * PropertyResourceConfigurer就是BeanFactoryPostProcessor的典型应用 * 将xml文件中的占位符替换成properties文件中相应的key对应的value */ @FunctionalInterface public interface BeanFactoryPostProcessor { /** * 在应用上下文完成了标准的初始化之后,修改其内部的bean工厂 * 将加载所有bean定义,但尚未实例化任何bean. * 我们可以覆盖或添加bean定义中的属性,甚至是提前初始化bean */ void postProcessBeanFactory(ConfigurableListableBeanFactory beanFactory) throws BeansException; }

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/wsppwz.html