Java Code Examples for org.springframework.context.support.PropertySourcesPlaceholderConfigurer#setIgnoreResourceNotFound()

The following examples show how to use org.springframework.context.support.PropertySourcesPlaceholderConfigurer#setIgnoreResourceNotFound() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MolgenisWebAppConfig.java    From molgenis with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer properties() throws IOException {
  AppDataRootInitializer.init();

  PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
  Resource[] resources =
      new Resource[] {
        new FileSystemResource(
            AppDataRootProvider.getAppDataRoot().toString()
                + File.separator
                + "molgenis-server.properties"),
        new ClassPathResource("/molgenis.properties")
      };
  pspc.setLocations(resources);
  pspc.setFileEncoding("UTF-8");
  pspc.setIgnoreUnresolvablePlaceholders(true);
  pspc.setIgnoreResourceNotFound(true);
  pspc.setNullValue("@null");
  return pspc;
}
 
Example 2
Source File: OverrideProperties.java    From sinavi-jfw with Apache License 2.0 6 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    MutablePropertySources propertySources = new MutablePropertySources();
    MockPropertySource source = new MockPropertySource()
        .withProperty("rabbitmq.host", "192.168.10.10")
        .withProperty("rabbitmq.port", "5673")
        .withProperty("rabbitmq.username", "jfw")
        .withProperty("rabbitmq.password", "jfw")
        .withProperty("rabbitmq.channel-cache-size", 100);
    propertySources.addLast(source);
    configurer.setPropertySources(propertySources);
    return configurer;
}
 
Example 3
Source File: InvalidProperties.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    MutablePropertySources propertySources = new MutablePropertySources();
    MockPropertySource source = new MockPropertySource()
        .withProperty("rabbitmq.port", "invalid");
    propertySources.addLast(source);
    configurer.setPropertySources(propertySources);
    return configurer;
}
 
Example 4
Source File: ExternalPropertyConfigurer.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
    properties.setLocation(new FileSystemResource("src/main/resources/external/conf.properties"));
    properties.setIgnoreResourceNotFound(false);
    return properties;
}
 
Example 5
Source File: CommitIdApplication.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeholderConfigurer() {
    PropertySourcesPlaceholderConfigurer c = new PropertySourcesPlaceholderConfigurer();
    c.setLocation(new ClassPathResource("git.properties"));
    c.setIgnoreResourceNotFound(true);
    c.setIgnoreUnresolvablePlaceholders(true);
    return c;
}
 
Example 6
Source File: AbstractMolgenisIntegrationTests.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
  PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
  Resource[] resources = new Resource[] {new ClassPathResource("/conf/molgenis.properties")};
  pspc.setLocations(resources);
  pspc.setFileEncoding("UTF-8");
  pspc.setIgnoreUnresolvablePlaceholders(true);
  pspc.setIgnoreResourceNotFound(true);
  pspc.setNullValue("@null");
  return pspc;
}
 
Example 7
Source File: PlatformITConfig.java    From molgenis with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
  PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
  Resource[] resources = new Resource[] {new ClassPathResource("/conf/molgenis.properties")};
  pspc.setLocations(resources);
  pspc.setFileEncoding("UTF-8");
  pspc.setIgnoreUnresolvablePlaceholders(true);
  pspc.setIgnoreResourceNotFound(true);
  pspc.setNullValue("@null");
  return pspc;
}
 
Example 8
Source File: RetryTestConsumerContextConfig.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    return configurer;
}
 
Example 9
Source File: DefaultProperties.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    MutablePropertySources propertySources = new MutablePropertySources();
    propertySources.addLast(new MockPropertySource());
    configurer.setPropertySources(propertySources);
    return configurer;
}
 
Example 10
Source File: NacosBeanUtils.java    From nacos-spring-project with Apache License 2.0 5 votes vote down vote up
/**
 * Register {@link PropertySourcesPlaceholderConfigurer} Bean
 *
 * @param registry {@link BeanDefinitionRegistry}
 * @param beanFactory {@link BeanFactory}
 */
public static void registerPropertySourcesPlaceholderConfigurer(
		BeanDefinitionRegistry registry, BeanFactory beanFactory) {
	registerInfrastructureBeanIfAbsent(registry, PLACEHOLDER_CONFIGURER_BEAN_NAME,
			PropertySourcesPlaceholderConfigurer.class);

	/*
	 * If you can't guarantee your old project properties file and config items are
	 * complete , please setIgnoreUnresolvablePlaceholders setIgnoreResourceNotFound
	 * is true 。 if not,you may not be able to start the spring container and your
	 * application
	 */

	boolean ignoreResourceNotFound = Boolean
			.parseBoolean(System.getProperty(IGNORE_RESOURCE_NOT_FOUND));
	boolean ignoreUnresolvablePlaceholders = Boolean
			.parseBoolean(System.getProperty(IGNORE_UNRESOLVABLE_PLACEHOLDERS));
	if (ignoreResourceNotFound || ignoreUnresolvablePlaceholders) {
		PropertySourcesPlaceholderConfigurer configurer = (PropertySourcesPlaceholderConfigurer) beanFactory
				.getBean(NacosBeanUtils.PLACEHOLDER_CONFIGURER_BEAN_NAME);
		if (configurer != null) {
			configurer.setIgnoreResourceNotFound(ignoreResourceNotFound);
			configurer.setIgnoreUnresolvablePlaceholders(
					ignoreUnresolvablePlaceholders);
		}
	}
}
 
Example 11
Source File: DefaultProperties.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    return configurer;
}
 
Example 12
Source File: OverrideProperties.java    From sinavi-jfw with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer placeHolderConfigurer() {
    PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    configurer.setIgnoreResourceNotFound(true);
    configurer.setIgnoreUnresolvablePlaceholders(true);
    return configurer;
}
 
Example 13
Source File: ProvisioningTestContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    pspc.setIgnoreResourceNotFound(true);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    return pspc;
}
 
Example 14
Source File: IdMLogicTestContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    pspc.setIgnoreResourceNotFound(true);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    return pspc;
}
 
Example 15
Source File: PersistenceTestContext.java    From syncope with Apache License 2.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    pspc.setIgnoreResourceNotFound(true);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    return pspc;
}
 
Example 16
Source File: SyncopeCoreApplication.java    From syncope with Apache License 2.0 5 votes vote down vote up
@ConditionalOnMissingBean(name = "propertySourcesPlaceholderConfigurer")
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    pspc.setIgnoreResourceNotFound(true);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    return pspc;
}
 
Example 17
Source File: PropertiesConfiguration.java    From Profiles-Blog with MIT License 5 votes vote down vote up
protected static PropertySourcesPlaceholderConfigurer createPropertySourcesPlaceholderConfigurer(Resource... resources) {
    final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
    ppc.setIgnoreUnresolvablePlaceholders(true);
    ppc.setIgnoreResourceNotFound(false);
    ppc.setLocations(resources);
    return ppc;
}