multiple parameters not getting passed when I start my spring boot application in command line

放肆的年华 提交于 2020-01-07 06:50:35

问题


I want to override certain properties during deployment of my spring boot application.

when I try the following it works

sudo /etc/init.d/myapp start --app.env=prod

I see the app.env is correctly set to prod (my /health just echoes this values)

however when I set more than one property it did not work,

sudo /etc/init.d/myapp start --app.env=prod --version=2.3.4

I see only app.env is correctly set. the version value is not overridden.

why is it so? what is the right way to pass multiple parameters.

NOTE: I want to pass username and password for datasources. but for testing purposes, I kept it simple to override these properties.


回答1:


You would want to read the section around Customizing the startup script. Specifically that you can include a myapp.conf file beside the jar file. In that .conf file is a JAVA_OPTS variable. You would then use -Dapp.env=prod -Dversion=2.3.4



来源:https://stackoverflow.com/questions/40095464/multiple-parameters-not-getting-passed-when-i-start-my-spring-boot-application-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!