[英]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?
作為如何構建Spring Boot jarfile的后續問題,systemd可直接作為服務執行? ,如何設置可執行Spring Boot jarfile的JVM屬性? 例如,如何設置最大堆大小(即-Xmx2048m
)?
這不是您問題的直接答案,而是解決方法。
我從未選擇使用可執行jar,因為我認為在應用程序啟動時從外部設置參數會更加靈活。
這是通過命令行設置JVM系統屬性和應用程序屬性的方法:
java -Xmx2048m -jar application.jar --paramname="paramvalue"
然后,您可以像這樣在Spring Bean或Service中獲取參數paramname
:
@Value("${paramname}")
private String paramname;
您可以在此處閱讀有關該主題的更多信息:
http://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
編輯
看一下這個答案,這似乎是您想要的:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.