/** * 继承上级上下文中的属性配置器 * * @param inheriting 上级上下文 * @param context 当前上下文 */ public static void inheritParentProperties(ApplicationContext inheriting, GenericApplicationContext context) { if (!(inheriting instanceof AbstractApplicationContext)) return; List<BeanFactoryPostProcessor> processors = ((AbstractApplicationContext) inheriting).getBeanFactoryPostProcessors(); for (BeanFactoryPostProcessor processor : processors) { if (processor instanceof PropertyResourceConfigurer) context.addBeanFactoryPostProcessor(processor); } }
@Bean public static PropertyResourceConfigurer propertySourcesPlaceholderConfigurer() { return new PropertySourcesPlaceholderConfigurer(); }
@Bean public static PropertyResourceConfigurer propertyResourceConfigurer() { return new PropertySourcesPlaceholderConfigurer(); }