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

The following examples show how to use org.springframework.context.support.PropertySourcesPlaceholderConfigurer#setLocations() . 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: ApplicationAutoConfiguration.java    From MaxKey with Apache License 2.0 6 votes vote down vote up
/**
 * propertySourcesPlaceholderConfigurer .
 * @return propertySourcesPlaceholderConfigurer
 * @throws IOException  null
 */
@Bean (name = "propertySourcesPlaceholderConfigurer")
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer()
        throws IOException {
    ClassPathResource classPathResource1 = 
            new ClassPathResource(ConstantsProperties.classPathResource(
                    ConstantsProperties.applicationPropertySource));
    ClassPathResource classPathResource2 = 
            new ClassPathResource(ConstantsProperties.classPathResource(
                    ConstantsProperties.maxKeyPropertySource));

    PropertySourcesPlaceholderConfigurer configurer = 
            new PropertySourcesPlaceholderConfigurer();
    configurer.setLocations(
            classPathResource1,
            classPathResource2
    );
    configurer.setIgnoreUnresolvablePlaceholders(true);
    _logger.debug("PropertySourcesPlaceholderConfigurer init");
    return configurer;
}
 
Example 2
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 3
Source File: MvcConfiguration.java    From aws-codedeploy-sample-tomcat with Apache License 2.0 5 votes vote down vote up
@Bean
public PropertySourcesPlaceholderConfigurer properties() {
    final PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
    try {
        configurer.setLocations(new PathMatchingResourcePatternResolver().getResources("file:/var/codedeploy/tomcat-sample/env.properties"));
    } catch (IOException e) {
        throw new RuntimeException("Failed to load resources.", e);
    }
    return configurer;
}
 
Example 4
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;
}
 
Example 5
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 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: PropertySourcesPlaceholderConfig.java    From tutorials with MIT License 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer properties(){
    PropertySourcesPlaceholderConfigurer pspc = new PropertySourcesPlaceholderConfigurer();
    Resource[] resources = new ClassPathResource[]{ new ClassPathResource("foo.properties") };
    pspc.setLocations(resources);
    pspc.setIgnoreUnresolvablePlaceholders(true);
    return pspc;
}
 
Example 8
Source File: ConfigLoader.java    From AIDR with GNU Affero General Public License v3.0 5 votes vote down vote up
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
	PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
	ClassPathResource locations[] = {
			new ClassPathResource("/application.properties"),
			new ClassPathResource("/environment.properties")};
	ppc.setLocations(locations);
	return ppc;
}
 
Example 9
Source File: RootConfig.java    From gerbil with GNU Affero General Public License v3.0 4 votes vote down vote up
static @Bean public PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() {
    PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
    Resource[] resourceLocations = new Resource[] { new ClassPathResource("gerbil.properties"), };
    p.setLocations(resourceLocations);
    return p;
}