0

We have a spring boot app with externalized configuration in a properties file. Executing the jar file like so works:
java -jar -Dspring.config.location="application.properties" app.jar

Executing the jar directly like below works, but without the properties file. Right now, none of these options below take the properties file.
./app.jar
./app.jar -Dspring.config.location="file:./application.properties"

I was hoping we could do something in the pom.xml or in the command that executes to achieve this.

FYI, we have this plugin in the pom.xml to build us the jar file:

            <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>
code4kix
  • 3,937
  • 5
  • 29
  • 44

1 Answers1

2

Create file: app.conf (filename is the same as your jar) with content:

JAVA_OPTS="-Dspring.config.location=application.properties"

Similar question was answered here. Documentation for customizing start script can be found here.

qavid
  • 533
  • 5
  • 9