我们有一个spring启动应用程序,在属性文件中有外部化的配置。执行jar文件如下:
java -jar -Dspring.config.location="application.properties" app.jar
像下面这样直接执行jar是可行的,但是没有属性文件。现在,下面的这些选项都不接受属性文件。
./app.jar
./app.jar -Dspring.config.location="file:./application.properties"
我希望我们能在未来做点什么pom.xml文件或者在执行的命令中。
仅供参考,我们在pom.xml 要为我们构建jar文件:
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<executable>true</executable>
<includeSystemScope>true</includeSystemScope>
<!-- This below does not work -->
<!-- <jvmArguments> -->
<!-- -Dspring.config.location=application.properties -->
<!-- </jvmArguments> -->
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
</goals>
</execution>
</executions>
</plugin>