Reputation: 28386
As a follow-up question to How do I build a Spring Boot jarfile that systemd can execute directly as a service?, how do I set the JVM properties of an executable Spring Boot jarfile? For example, how do I set the maximum heap size (i.e. -Xmx2048m
)?
Upvotes: 0
Views: 4907
Reputation: 14551
This is not a direct answer to your question, but a way how to work around.
I have never opted for an executable jar since I believe it's more flexible to set the parameters from outside at app startup.
This is how to set JVM system properties and application properties via command line:
java -Xmx2048m -jar application.jar --paramname="paramvalue"
You can then get the parameter paramname
in a Spring Bean or Service like this:
@Value("${paramname}")
private String paramname;
You can read more about that topic here:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
Edit
Take a look at this answer which seems to be what you're looking for:
https://stackoverflow.com/a/33856394/272180
Upvotes: 1
Reputation: 3620
Place your-app.conf
next to your-app.jar
with content
JAVA_OPTS=-Xmx2048M
Refer to deployment script customization guide or launch.script for details.
Upvotes: 2
Reputation: 28386
_JAVA_OPTIONS
.JAVA_TOOL_OPTIONS
also sets the JVM properties.Upvotes: 0