运行git 2.2.4
我试图使属性(yml)属性在jar文件之外可用。
项目:
~/Documents/NetbeansProjects/myApp/src/main/resources
application.yml
application-dev.yml
application-stage.yml
~/Documents/NetbeansProjects/myApp/target myApp.jar
~/Documents/NetbeansProjects/myApp/target/config/
application.yml
jdbc.yml
~/Documents/NetbeansProjects/myApp/target:
java -jar myApp.jar --spring.config.name=application,jdbc --spring.config.location=file:~/Documents/NetbeansProjects/myApp/target/config/我得到的只是弹簧横幅和弹簧靴的终止?
使用jar工作中的属性从Netbeans或从git bash运行。
发布于 2020-02-09 03:15:10
实现这一目标的途径有多种:
Programmatically
public PropertySourcesPlaceholderConfigurer propertySourcesPlaceholderConfigurer() {
PropertySourcesPlaceholderConfigurer properties = new PropertySourcesPlaceholderConfigurer();
properties.setLocation(new FileSystemResource("/Users/home/conf.properties"));
properties.setIgnoreResourceNotFound(false);
return properties;
}环境变量
导出SPRING_CONFIG_NAME=application
导出SPRING_CONFIG_LOCATION=file:///Users/home/config
java -jar app.jar
命令行
--spring.config.location=file:///Users/home/config/jdbc.properties
java -jar app.jar
希望它能帮上忙
https://stackoverflow.com/questions/60132529
复制相似问题