本文整理匯總了Java中org.springframework.context.support.PropertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound方法的典型用法代碼示例。如果您正苦於以下問題:Java PropertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound方法的具體用法?Java PropertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound怎麽用?Java PropertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.springframework.context.support.PropertySourcesPlaceholderConfigurer
的用法示例。
在下文中一共展示了PropertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: propertySourcesPlaceholderConfigurer
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
AppResourceLoader propertyLoader = new PropertyResourceLoader();
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
configurer.setIgnoreResourceNotFound(Boolean.FALSE);
configurer.setLocation(propertyLoader.find());
return configurer;
}
示例2: propertySourcesPlaceholderConfigurer
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() throws IOException {
AppResourceLoader propertyLoader = new PropertyResourceLoader();
PropertySourcesPlaceholderConfigurer configurer = new PropertySourcesPlaceholderConfigurer();
configurer.setIgnoreResourceNotFound(Boolean.FALSE);
configurer.setLocation(propertyLoader.find());
return configurer;
}
示例3: properties
import org.springframework.context.support.PropertySourcesPlaceholderConfigurer; //導入方法依賴的package包/類
@Bean
public static PropertySourcesPlaceholderConfigurer properties() {
PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer = new PropertySourcesPlaceholderConfigurer();
propertySourcesPlaceholderConfigurer.setIgnoreResourceNotFound(false);
ArrayList<String> defaultSources = new ArrayList(Arrays.asList("raptor.yml", appName + ".yml"));
if (additionalConfigNames != null && !additionalConfigNames.isEmpty()) {
defaultSources.addAll(additionalConfigNames);
}
ArrayList<String> sources = new ArrayList(defaultSources);
if (developmentMode) {
defaultSources.forEach((source) -> {
sources.add(source.replace(".yml", ".dev.yml"));
});
}
try {
String envPath = System.getenv("CONFIG_BASEPATH");
if (envPath != null && envPath.isEmpty()) {
log.debug("Using CONFIG_BASEPATH={}", envPath);
basepath = envPath;
}
} catch (Exception e) {
log.warn("Failed to read environment variable CONFIG_BASEPATH: %s", e.getMessage());
}
log.debug("Configuration path {}", basepath);
List<Resource> resources = sources.stream()
.filter(f -> new File(basepath + f).exists())
.map(f -> new FileSystemResource(basepath + f))
.collect(Collectors.toList());
log.debug("Configuration sources: {}", resources.toString());
if (resources.isEmpty()) {
throw new RuntimeException("Cannot find a loadable property file in: " + basepath);
}
YamlPropertiesFactoryBean yaml = new YamlPropertiesFactoryBean();
yaml.setResources(resources.toArray(new Resource[]{}));
propertySourcesPlaceholderConfigurer.setProperties(yaml.getObject());
return propertySourcesPlaceholderConfigurer;
}