【发布时间】:2019-09-12 12:49:17
【问题描述】:
我有一个 demoApp 项目,文件夹中有 application.properties
/src/main/resources
现在我想将 application.properties 存储在某个位置,例如:
C:\Users\lenovo\Desktop\externalResource\resources
我尝试了一些工作,比如在 setenv.bat 文件中设置配置位置,比如
set spring.config.location=C:\Users\lenovo\Desktop\externalResource\resources\
也用于将系统环境中的路径设置为:
CONF_DIR = C:\Users\lenovo\Desktop\externalResource\resources\
并尝试使用如下代码访问:
public static PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer propertySource = new PropertySourcesPlaceholderConfigurer();
ClassPathResource[] resource = new ClassPathResource[]{new ClassPathResource("file:${CONF_DIR}/application-external.properties")};
propertySource.setLocations(resource);
propertySource.setIgnoreUnresolvablePlaceholders(true);
return propertySource;
}
上一个问题中提供的以前的解决方案都不适合我。 我在这里缺少什么?
【问题讨论】: