当我在命令行中启动我的 Spring Boot 应用程序时,多个参数没有被传递 [英] multiple parameters not getting passed when I start my spring boot application in command line

查看:17
本文介绍了当我在命令行中启动我的 Spring Boot 应用程序时,多个参数没有被传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在部署 Spring Boot 应用程序期间覆盖某些属性.

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

当我尝试以下操作时

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

我看到 app.env 被正确设置为 prod(我的 /health 只是回应这个值)

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

我看到只有 app.env 设置正确.版本值不会被覆盖.

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.

推荐答案

您可能需要阅读有关 自定义启动脚本.具体来说,您可以在 jar 文件旁边包含一个 myapp.conf 文件.在那个 .conf 文件中是一个 JAVA_OPTS 变量.然后你会使用 -Dapp.env=prod -Dversion=2.3.4

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

这篇关于当我在命令行中启动我的 Spring Boot 应用程序时,多个参数没有被传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆