Java 类org.springframework.context.support.PropertySourcesPlaceholderConfigurer 实例源码

项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
@Profile("integration")
public static PropertySourcesPlaceholderConfigurer propertiesForIntegration()
        throws Exception {
    String file = "application-integration-local.properties";

    String envIntegration = System.getenv("CLOUDUNIT_JENKINS_CI");
    if ("true".equalsIgnoreCase(envIntegration)) {
        file = "application-integration.properties";
    }

    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
项目:xproject    文件:GlobalPropertySources.java   
protected void mergePropertySource() throws Exception {
    if (this.environment != null) {
        this.addLast(new PropertySource<Environment>(PropertySourcesPlaceholderConfigurer.ENVIRONMENT_PROPERTIES_PROPERTY_SOURCE_NAME, this.environment) {
            public String getProperty(String key) {
                return this.source.getProperty(key);
            }
        });
    } else {
        logger.warn("The injected environment was null!");
    }
    if (this.locations != null && this.locations.length > 0) {
        Properties localProperties = new Properties();
        loadProperties(localProperties);
        PropertySource<?> localPropertySource = new PropertiesPropertySource(PropertySourcesPlaceholderConfigurer.LOCAL_PROPERTIES_PROPERTY_SOURCE_NAME, localProperties);
        if (this.localOverride) {
            this.addFirst(localPropertySource);
        } else {
            this.addLast(localPropertySource);
        }
    }
}
项目:apollo-custom    文件:ApolloConfigRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata
      .getAnnotationAttributes(EnableApolloConfig.class.getName()));
  String[] namespaces = attributes.getStringArray("value");
  int order = attributes.getNumber("order");
  PropertySourcesProcessor.addNamespaces(Lists.newArrayList(namespaces), order);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesProcessor.class.getName(),
      PropertySourcesProcessor.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
项目:lodsve-framework    文件:LodsveCoreConfiguration.java   
@Bean
public static PropertySourcesPlaceholderConfigurer propertyPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer placeholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    placeholderConfigurer.setFileEncoding("UTF-8");

    Properties properties = EnvLoader.getEnvs();
    if (properties.isEmpty()) {
        ParamsHome.getInstance().init(StringUtils.EMPTY);
        EnvLoader.init();
        IniLoader.init();

        properties = EnvLoader.getEnvs();
    }

    placeholderConfigurer.setProperties(properties);

    return placeholderConfigurer;
}
项目:apollo    文件:ApolloConfigRegistrar.java   
@Override
public void registerBeanDefinitions(AnnotationMetadata importingClassMetadata, BeanDefinitionRegistry registry) {
  AnnotationAttributes attributes = AnnotationAttributes.fromMap(importingClassMetadata
      .getAnnotationAttributes(EnableApolloConfig.class.getName()));
  String[] namespaces = attributes.getStringArray("value");
  int order = attributes.getNumber("order");
  PropertySourcesProcessor.addNamespaces(Lists.newArrayList(namespaces), order);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesProcessor.class.getName(),
      PropertySourcesProcessor.class);

  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
项目:spring-boot-concourse    文件:EmbeddedWebApplicationContextTests.java   
@Test
public void postProcessEmbeddedServletContainerFactory() throws Exception {
    RootBeanDefinition bd = new RootBeanDefinition(
            MockEmbeddedServletContainerFactory.class);
    MutablePropertyValues pv = new MutablePropertyValues();
    pv.add("port", "${port}");
    bd.setPropertyValues(pv);
    this.context.registerBeanDefinition("embeddedServletContainerFactory", bd);

    PropertySourcesPlaceholderConfigurer propertySupport = new PropertySourcesPlaceholderConfigurer();
    Properties properties = new Properties();
    properties.put("port", 8080);
    propertySupport.setProperties(properties);
    this.context.registerBeanDefinition("propertySupport",
            beanDefinition(propertySupport));

    this.context.refresh();
    assertThat(getEmbeddedServletContainerFactory().getContainer().getPort())
            .isEqualTo(8080);
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:EmbeddedWebApplicationContextTests.java   
@Test
public void postProcessEmbeddedServletContainerFactory() throws Exception {
    RootBeanDefinition bd = new RootBeanDefinition(
            MockEmbeddedServletContainerFactory.class);
    MutablePropertyValues pv = new MutablePropertyValues();
    pv.add("port", "${port}");
    bd.setPropertyValues(pv);
    this.context.registerBeanDefinition("embeddedServletContainerFactory", bd);

    PropertySourcesPlaceholderConfigurer propertySupport = new PropertySourcesPlaceholderConfigurer();
    Properties properties = new Properties();
    properties.put("port", 8080);
    propertySupport.setProperties(properties);
    this.context.registerBeanDefinition("propertySupport",
            beanDefinition(propertySupport));

    this.context.refresh();
    assertThat(getEmbeddedServletContainerFactory().getContainer().getPort())
            .isEqualTo(8080);
}
项目:setaria    文件:ConfigValueBeanFactoryPostProcessor.java   
public void postProcess(ConfigurableListableBeanFactory beanFactory) {
    // 注册 Spring 属性配置
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    MutablePropertySources mutablePropertySources = new MutablePropertySources();
    mutablePropertySources.addLast(new PropertySource<String>(Configs.class.getName()) {
        @Override
        public String getProperty(String name) {
            return Configs.getString(name);
        }
    });
    configurer.setPropertySources(mutablePropertySources);
    configurer.postProcessBeanFactory(beanFactory);

    /*
     * 注册 @ConfigValue 处理器. ConfigValueBeanPostProcessor 实现了 ApplicationListener 接口, 不能使用
     * beanFactory.addBeanPostProcessor() 来注册实例.
     */
    beanFactory.registerSingleton(ConfigValueBeanPostProcessor.class.getName(),
            new ConfigValueBeanPostProcessor(beanFactory));
}
项目:elastic-config    文件:PlaceholderResolved.java   
public Optional<Resource[]> getPlaceholderConfigurerResources() {

        List<Resource> resources = Lists.newArrayList();
        Iterator<Entry<String, PropertySourcesPlaceholderConfigurer>> iterator = placeholderMap.entrySet().iterator();
        while (iterator.hasNext()) {
            Entry<String, PropertySourcesPlaceholderConfigurer> entry = iterator.next();
            Optional<Resource[]> optional = this.<Resource[]> getPropertyValue(entry.getValue(),
                PropertySourcesEnum.LOCATIONS.getName());

            if (optional.isPresent()) {
                resources.addAll(Arrays.asList(optional.get()));
            }
        }

        return Optional.fromNullable(resources.toArray(new Resource[0]));
    }
项目:configx    文件:ConfigPropertyResolver.java   
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
项目:configx    文件:ConfigPropertyResolver.java   
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
    // Take care not to cause early instantiation of all FactoryBeans
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
        Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory
                .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false,
                        false);
        if (beans.size() == 1) {
            return beans.values().iterator().next();
        }
    }
    return null;
}
项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
@Profile("vagrant")
public static PropertySourcesPlaceholderConfigurer properties()
        throws Exception {
    String file = "application-vagrant.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
@Profile("production")
public static PropertySourcesPlaceholderConfigurer propertiesForProduction()
        throws Exception {
    String file = "application-production.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
@Profile("vagrant-demo")
public static PropertySourcesPlaceholderConfigurer propertiesForDemo()
        throws Exception {
    String file = "application-vagrant-demo.properties";
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    pspc.setLocations(getResources(file));
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
项目:devops-cstack    文件:CloudUnitApplicationContext.java   
@Bean
@Profile("test")
public static PropertySourcesPlaceholderConfigurer propertiesForTest()
        throws Exception {
    PropertySourcesPlaceholderConfigurer pspc =
            new PropertySourcesPlaceholderConfigurer();
    Resource[] resources = new Resource[]
            {new ClassPathResource("application-test.properties")};
    pspc.setLocations(resources);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    pspc.setLocalOverride(true);
    return pspc;
}
项目:scrumtracker2017    文件:ApplicationContext.java   
@Bean
public static PropertySourcesPlaceholderConfigurer properties()
{
    PropertySourcesPlaceholderConfigurer propertySources = new PropertySourcesPlaceholderConfigurer();
    //propertySources.setIgnoreUnresolvablePlaceholders(true);
    return propertySources;
}
项目:learn-spring-5    文件:PropertyConfig.java   
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer =
            new PropertySourcesPlaceholderConfigurer();
    return propertySourcesPlaceholderConfigurer;

}
项目:mango-spring-boot-starter    文件:MangoConfigFactory.java   
private static PropertySources deducePropertySources(DefaultListableBeanFactory beanFactory) {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer(beanFactory);
    if (configurer != null) {
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    Environment environment = new StandardEnvironment();
    MutablePropertySources propertySources = ((ConfigurableEnvironment) environment).getPropertySources();
    return new FlatPropertySources(propertySources);

}
项目:mango-spring-boot-starter    文件:MangoConfigFactory.java   
private static PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer(DefaultListableBeanFactory beanFactory) {
    Map<String, PropertySourcesPlaceholderConfigurer> beans = beanFactory.getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false, false);
    if (beans.size() == 1) {
        return beans.values().iterator().next();
    }
    return null;
}
项目:lams    文件:PropertyPlaceholderBeanDefinitionParser.java   
@Override
protected Class<?> getBeanClass(Element element) {
    // As of Spring 3.1, the default value of system-properties-mode has changed from
    // 'FALLBACK' to 'ENVIRONMENT'. This latter value indicates that resolution of
    // placeholders against system properties is a function of the Environment and
    // its current set of PropertySources
    if (element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIB).equals(SYSTEM_PROPERTIES_MODE_DEFAULT)) {
        return PropertySourcesPlaceholderConfigurer.class;
    }

    // the user has explicitly specified a value for system-properties-mode. Revert
    // to PropertyPlaceholderConfigurer to ensure backward compatibility.
    return PropertyPlaceholderConfigurer.class;
}
项目:RFTBackend    文件:CustomYamlConfig.java   
@Bean
public PropertySourcesPlaceholderConfigurer properties() {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    YamlPropertiesFactoryBean yamlPropertiesFactory = new YamlPropertiesFactoryBean();
    ConfigurationFileResourceResolver configurationFileResourceResolver = new ConfigurationFileResourceResolver();

    yamlPropertiesFactory.setResources(configurationFileResourceResolver.getResourceArray());
    propertySourcesPlaceholderConfigurer.setProperties(yamlPropertiesFactory.getObject());

    return propertySourcesPlaceholderConfigurer;
}
项目:flow-platform    文件:WebConfig.java   
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    AppResourceLoader propertyLoader = new PropertyResourceLoader();

    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(Boolean.FALSE);
    configurer.setLocation(propertyLoader.find());

    return configurer;
}
项目:flow-platform    文件:WebConfig.java   
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    AppResourceLoader propertyLoader = new PropertyResourceLoader();
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(Boolean.FALSE);
    configurer.setLocation(propertyLoader.find());
    return configurer;
}
项目:jwala    文件:AemServiceConfiguration.java   
/**
 * Make vars.properties available to spring integration configuration
 * System properties are only used if there is no setting in vars.properties.
 */
@Bean(name = "aemServiceConfigurationPropertiesConfigurer")
public static PropertySourcesPlaceholderConfigurer configurer() {
    PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setLocation(new ClassPathResource("META-INF/spring/jwala-defaults.properties"));
    ppc.setLocalOverride(true);
    ppc.setProperties(ApplicationProperties.getProperties());
    return ppc;
}
项目:apollo-custom    文件:ConfigPropertySourcesProcessor.java   
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);
  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
项目:spring-boot-concourse    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
    // Take care not to cause early instantiation of all FactoryBeans
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
        Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory
                .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false,
                        false);
        if (beans.size() == 1) {
            return beans.values().iterator().next();
        }
    }
    return null;
}
项目:elastic-config    文件:PlaceholderResolved.java   
@SuppressWarnings("unchecked")
@SneakyThrows
private <T> Optional<T> getPropertyValue(PropertySourcesPlaceholderConfigurer placeholderConfigurer, String property) {
    Field field = ReflectionUtils.findField(placeholderConfigurer.getClass(), property);
    ReflectionUtils.makeAccessible(field);
    return Optional.fromNullable((T) field.get(placeholderConfigurer));
}
项目:spring-boot-concourse    文件:AutoConfigurationReproTests.java   
@Test
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
    SpringApplication application = new SpringApplication(EarlyInitConfig.class,
            PropertySourcesPlaceholderConfigurer.class,
            EmbeddedServletContainerAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class);
    this.context = application.run("--server.port=0");
    String bean = (String) this.context.getBean("earlyInit");
    assertThat(bean).isEqualTo("bucket");
}
项目:apollo    文件:ConfigPropertySourcesProcessor.java   
@Override
public void postProcessBeanDefinitionRegistry(BeanDefinitionRegistry registry) throws BeansException {
  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, PropertySourcesPlaceholderConfigurer.class.getName(),
      PropertySourcesPlaceholderConfigurer.class);
  BeanRegistrationUtil.registerBeanDefinitionIfNotExists(registry, ApolloAnnotationProcessor.class.getName(),
      ApolloAnnotationProcessor.class);
}
项目:elastic-config    文件:PlaceholderResolved.java   
/**
 * 易变属性源
 * 
 * @param placeholderConfigurer 占位符配置器
 * @return 易变属性源
 */
private MutablePropertySources mergePropertySources(PropertySourcesPlaceholderConfigurer placeholderConfigurer) {

    Optional<MutablePropertySources> multablePropertySources = getPropertySourcesSources(placeholderConfigurer);

    if (multablePropertySources.isPresent()) {
        multablePropertySources.get().addLast(registryPropertySource);
        return multablePropertySources.get();
    }

    return this.builder(placeholderConfigurer).environmentSources().localPropertiesSources().elastiConfigSources()
        .bulid();
}
项目:graviteeio-access-management    文件:EnvironmentConfiguration.java   
@Bean
public static PropertySourcesPlaceholderConfigurer properties(@Qualifier("graviteeProperties") Properties graviteeProperties) {
    PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
    propertySourcesPlaceholderConfigurer.setProperties(graviteeProperties);
    propertySourcesPlaceholderConfigurer.setIgnoreUnresolvablePlaceholders(true);

    return propertySourcesPlaceholderConfigurer;
}
项目:my-spring-cache-redis    文件:PropertyPlaceholderBeanDefinitionParser.java   
@Override
protected Class<?> getBeanClass(Element element) {
    // As of Spring 3.1, the default value of system-properties-mode has changed from
    // 'FALLBACK' to 'ENVIRONMENT'. This latter value indicates that resolution of
    // placeholders against system properties is a function of the Environment and
    // its current set of PropertySources
    if (element.getAttribute(SYSTEM_PROPERTIES_MODE_ATTRIB).equals(SYSTEM_PROPERTIES_MODE_DEFAULT)) {
        return PropertySourcesPlaceholderConfigurer.class;
    }

    // the user has explicitly specified a value for system-properties-mode. Revert
    // to PropertyPlaceholderConfigurer to ensure backward compatibility.
    return PropertyPlaceholderConfigurer.class;
}
项目:smt-spring-security-parent    文件:JwtSpringSecurityAdaptor.java   
private void autowireThis(HttpSecurity http) {
    final ApplicationContext parent = http.getSharedObject(ApplicationContext.class);
    checkForJwtAnnotation(parent);

    final AnnotationConfigApplicationContext context = new AnnotationConfigApplicationContext();
    context.setParent(parent);
    context.register(PropertySourcesPlaceholderConfigurer.class);
    context.register(getClass());
    context.refresh();
    context.getAutowireCapableBeanFactory().autowireBean(this);
}
项目:elastic-config    文件:PlaceholderResolved.java   
public static Optional<PropertiesPropertySource> getLocalPropertiesSources(
    PropertySourcesPlaceholderConfigurer placeholderConfigurer) {

    Method method = ReflectionUtils.findMethod(placeholderConfigurer.getClass(),
        PropertySourcesEnum.MERGEPROPERTIES.getName());
    ReflectionUtils.makeAccessible(method);
    Properties properties = (java.util.Properties) ReflectionUtils.invokeMethod(method, placeholderConfigurer);
    return Optional.fromNullable(new PropertiesPropertySource(PropertySourcesEnum.LOCALPROPERTIES.getName(),
        properties));
}
项目:elastic-config    文件:PlaceholderResolved.java   
/**
 * 初始化PlaceholderMap
 * 
 * @param beanFactory 可配置列表Bean工厂
 * @return placeholderMap
 */
private Map<String, PropertySourcesPlaceholderConfigurer> initPlaceholderMap(
    final ConfigurableListableBeanFactory beanFactory) {

    Map<String, PropertySourcesPlaceholderConfigurer> placeholderMap = beanFactory.getBeansOfType(
        PropertySourcesPlaceholderConfigurer.class, true, false);
    if (placeholderMap.isEmpty()) {
        beanFactory.registerSingleton(PropertySourcesPlaceholderConfigurer.class.getCanonicalName(),
            new PropertySourcesPlaceholderConfigurer());
        placeholderMap = beanFactory.getBeansOfType(PropertySourcesPlaceholderConfigurer.class);
    }
    return placeholderMap;
}
项目:spring-boot-concourse    文件:ConditionalOnBeanTests.java   
@Test
public void withPropertyPlaceholderClassName() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "mybeanclass=java.lang.String");
    this.context.register(PropertySourcesPlaceholderConfigurer.class,
            WithPropertyPlaceholderClassName.class, OnBeanClassConfiguration.class);
    this.context.refresh();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySources deducePropertySources() {
    PropertySourcesPlaceholderConfigurer configurer = getSinglePropertySourcesPlaceholderConfigurer();
    if (configurer != null) {
        // Flatten the sources into a single list so they can be iterated
        return new FlatPropertySources(configurer.getAppliedPropertySources());
    }
    if (this.environment instanceof ConfigurableEnvironment) {
        MutablePropertySources propertySources = ((ConfigurableEnvironment) this.environment)
                .getPropertySources();
        return new FlatPropertySources(propertySources);
    }
    // empty, so not very useful, but fulfils the contract
    return new MutablePropertySources();
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesBindingPostProcessor.java   
private PropertySourcesPlaceholderConfigurer getSinglePropertySourcesPlaceholderConfigurer() {
    // Take care not to cause early instantiation of all FactoryBeans
    if (this.beanFactory instanceof ListableBeanFactory) {
        ListableBeanFactory listableBeanFactory = (ListableBeanFactory) this.beanFactory;
        Map<String, PropertySourcesPlaceholderConfigurer> beans = listableBeanFactory
                .getBeansOfType(PropertySourcesPlaceholderConfigurer.class, false,
                        false);
        if (beans.size() == 1) {
            return beans.values().iterator().next();
        }
    }
    return null;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:AutoConfigurationReproTests.java   
@Test
public void doesNotEarlyInitializeFactoryBeans() throws Exception {
    SpringApplication application = new SpringApplication(EarlyInitConfig.class,
            PropertySourcesPlaceholderConfigurer.class,
            EmbeddedServletContainerAutoConfiguration.class,
            ServerPropertiesAutoConfiguration.class);
    this.context = application.run("--server.port=0");
    String bean = (String) this.context.getBean("earlyInit");
    assertThat(bean).isEqualTo("bucket");
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConditionalOnBeanTests.java   
@Test
public void withPropertyPlaceholderClassName() throws Exception {
    EnvironmentTestUtils.addEnvironment(this.context, "mybeanclass=java.lang.String");
    this.context.register(PropertySourcesPlaceholderConfigurer.class,
            WithPropertyPlaceholderClassName.class, OnBeanClassConfiguration.class);
    this.context.refresh();
}