下面列出了org.springframework.context.support.PropertySourcesPlaceholderConfigurer#setLocations ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
/**
* 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;
}
@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;
}
@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;
}
protected static PropertySourcesPlaceholderConfigurer createPropertySourcesPlaceholderConfigurer(Resource... resources) {
final PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ppc.setIgnoreUnresolvablePlaceholders(true);
ppc.setIgnoreResourceNotFound(false);
ppc.setLocations(resources);
return ppc;
}
@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;
}
@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;
}
@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;
}
@Bean
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer ppc = new PropertySourcesPlaceholderConfigurer();
ClassPathResource locations[] = {
new ClassPathResource("/application.properties"),
new ClassPathResource("/environment.properties")};
ppc.setLocations(locations);
return ppc;
}
static @Bean public PropertySourcesPlaceholderConfigurer myPropertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer p = new PropertySourcesPlaceholderConfigurer();
Resource[] resourceLocations = new Resource[] { new ClassPathResource("gerbil.properties"), };
p.setLocations(resourceLocations);
return p;
}