Nav
Nav

Reputation: 4540

Override jvmArguments for Maven spring boot plugin

I have this plugin config in my pomn:

<plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <configuration>
                <jvmArguments>
                     -Djavax.net.ssl.trustStore=${project.build.outputDirectory}/keystore.jks
                     -Djavax.net.ssl.trustStorePassword=ue90D3v
                     -Djavax.net.ssl.keyStore=${project.build.outputDirectory}/keystore.jks
                     -Djavax.net.ssl.keyStorePassword=ue90D3v
                </jvmArguments>
            </configuration>
        </plugin>
    </plugins>

So I can run app perfectly by mvn spring-boot:run. But what if I want to override arguments, for example "javax.net.ssl.trustStore". I expect this command works:

mvn spring-boot:run -Djavax.net.ssl.trustStore=<other_location>

But it doesn't. Also I tried this and not working :

mvn -Dspring-boot.run.jvmArguments="-Djavax.net.ssl.trustStore=other_location" spring-boot:run

Also it would be a solution if I can set JAVA_OPTS in pom.

Upvotes: 4

Views: 9107

Answers (2)

Y.M.
Y.M.

Reputation: 659

facing the same problem, you can do this:

<properties>
  <!-- defined here if you don't use -Dspring-boot.run.jvmArguments-->
  <spring-boot.run.jvmArguments></spring-boot.run.jvmArguments>
</properties>
<build>
<plugins>
    <plugin>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-maven-plugin</artifactId>
        <configuration>
            <jvmArguments>
                 -Djavax.net.ssl.trustStore=${project.build.outputDirectory}/keystore.jks
                 -Djavax.net.ssl.trustStorePassword=ue90D3v
                 -Djavax.net.ssl.keyStore=${project.build.outputDirectory}/keystore.jks
                 -Djavax.net.ssl.keyStorePassword=ue90D3v 
                 ${spring-boot.run.jvmArguments}
            </jvmArguments>
        </configuration>
    </plugin>
</plugins>
</build>

and starting you app with:

mvn -Dspring-boot.run.jvmArguments="-Djavax.net.ssl.trustStore=other_location" spring-boot:run

Upvotes: 8

bittu
bittu

Reputation: 806

Try this :

mvn spring-boot:run -Dspring-boot.run.jvmArguments="-Djavax.net.ssl.trustStore=other_location"

Doc link : https://docs.spring.io/spring-boot/docs/current/maven-plugin/examples/run-debug.html

Used the same in past for some other arguments.

Upvotes: 0

Related Questions