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
)?
Asked
Active
Viewed 4,041 times
0

Community
- 1
- 1

Derek Mahar
- 27,608
- 43
- 124
- 174
-
From a shell-script I guess. – kometen Nov 30 '16 at 16:37
-
Is that the only way? – Derek Mahar Nov 30 '16 at 16:40
-
see this http://stackoverflow.com/questions/23072187/how-to-configure-heap-size-when-start-a-spring-boot-application-with-embedded-to?rq=1 – Saravana Nov 30 '16 at 16:42
-
@Saravana, that question doesn't apply because my application doesn't use embedded Tomcat. – Derek Mahar Nov 30 '16 at 16:48
3 Answers
2
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.

tan9
- 3,490
- 2
- 18
- 21
1
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: