向Spring Boot应用添加其他参数 [英] Add additional parameters to Spring Boot app
问题描述
I am wondering if it's possible to add spring's additional parameters such as -Dspring.profiles.active=prod
to spring boot app in case of running it as a service.
我检查了spring-boot-maven-plugin
自动生成的脚本:
I checked the script that was generated automatically by spring-boot-maven-plugin
:
command="$javaexe -jar -Dsun.misc.URLClassPath.disableJarChecking=true $jarfile $@"
所以也许可以通过maven插件的选项来完成,但是除了JVM参数之外,找不到任何其他有用的东西...
so maybe it can be done via maven plugin's options, but couldn't find any except of JVM arguments which is not so useful...
推荐答案
我找不到任何解决方案,包括我所描述的解决方案-似乎插件的其他参数也不起作用.
I couldn't find any solution including the one I described in question - it seems that plugin's additional params also don't work.
最后,我使用看起来像这样,并且效果很好:
Looks like that and works perfectly:
[Unit]
Description=Some app
After=syslog.target
[Service]
ExecStart=java -Dspring.profiles.active=production -jar /home/apps/monitoring-app-1.0.0.jar
[Install]
WantedBy=multi-user.target
这篇关于向Spring Boot应用添加其他参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!