Spring boot Jar文件之外的Spring2.x属性 弹簧2.2.4 jdk8 运行GitBash的Windows10 弹簧靴起动器 弹簧靴开发工具 弹簧靴执行器 SpringBootStarterWeb

Spring boot Jar文件之外的Spring2.x属性 弹簧2.2.4 jdk8 运行GitBash的Windows10 弹簧靴起动器 弹簧靴开发工具 弹簧靴执行器 SpringBootStarterWeb,spring-boot,Spring Boot,我试图使属性(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/ applic

我试图使属性(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 mvn运行。

有多种方法可以实现它:
以编程方式

公共属性资源占位符配置器属性资源占位符配置器(){
PropertySourcesPlaceholderConfigurer properties=新的PropertySourcesPlaceholderConfigurer();
setLocation(新文件系统资源(“/Users/home/conf.properties”);
properties.setIgnoreResourceNotFound(false);
归还财产;
}

环境变量

export SPRING\u CONFIG\u NAME=应用程序,jdbc
导出SPRING\u配置\u位置=file:///Users/home/config
java-jarapp.jar

命令行

java-jar app.jar--spring.config.location=file:///Users/home/config/jdbc.properties


希望它有帮助

“我得到的只是spring横幅和spring boot的终止”。请提供准确的输出,并在第一次尝试诊断时,将
org.springframework
日志级别提高到debugNot Interest in Programming或environment variable solution。我会在环境上使用全局解决方案:DevTools.config/spring boot/sring-boot-DevTools.yml,即使在将应用程序-(env.yml)移出src/main/resources时,它也不能与--spring.config.name(带或不带spring-config.location)一起工作