Spring Boot executable JAVA_OPTS override with spaces
Solution 1
What I ended up doing was using an externalised application.yml
per the instructions here. Still not exactly what I wanted, but it'll do for now.
Solution 2
Had the same problem and found that escaping the embedded double quotes with backslash did the trick, like this:
JAVA_OPTS="-Dmy.param=\"One Two\" -Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit"
Comments
-
Catchwa almost 2 years
I'm using Spring Boot 1.4.1 to create an executable Unix JAR file (per the instructions here). I'm using a custom .conf file to set the
JAVA_OPTS
value at run-time. This has been working fine with the following contents:JAVA_OPTS="-Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit"
I now want to override a parameter that I've got configured in my application.yml file (that's embedded within the JAR). The problem is that the values of this parameter have spaces in them.
I've tried:
JAVA_OPTS="-Dmy.param=One Two -Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit"
...and...
JAVA_OPTS="-Dmy.param=One\ Two -Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit"
...and...
JAVA_OPTS=-Dmy.param=One\ Two -Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit
...and...
JAVA_OPTS=""-Dmy.param=One\ Two" -Dspring.profiles.active=prod -Dflyway.validate-on-migrate=false -Djavax.net.ssl.trustStore=/var/myapp/truststore.jks -Djavax.net.ssl.trustStorePassword=changeit"
But I get various error messages like:
Error: Could not find or load main class Two
...or...
/var/myapp/myapp.conf line 1: Two: command not found
I've looked inside the code that's embedded in the top of the JAR file and it seems to be:
arguments=(-Dsun.misc.URLClassPath.disableJarChecking=true $JAVA_OPTS -jar $jarfile $RUN_ARGS "$@")
...but I'm having trouble working out how to translate this into a JAVA_OPTS value that works