简体   繁体   English

在 SysV Centos6 中使用环境变量

[英]Using Environment Variables with SysV Centos6

I have a Spring Boot application that I installed as a service in SysV , so I created a Symbolic link in /etc/init.d/myapp to /home/myuser/app.jar.我有一个 Spring 引导应用程序,我在SysV中作为服务安装,所以我在 /etc/init.d/myapp 中创建了一个指向 /home/myuser/app.jar 的符号链接。

Then I start my application in this way:然后我以这种方式启动我的应用程序:

service app start --spring.config.location=application.properties

Inside my application.properties I expect an environment variable, see:在我的 application.properties 中,我需要一个环境变量,请参阅:

app.info.version=${APP_VERSION}

I always execute export APP_VERSION=1 before start my service but ${APP_VERSION} is always empty.我总是在启动服务之前执行export APP_VERSION=1但 ${APP_VERSION} 总是为空。 Then I tried to execute manually in this way:然后我尝试以这种方式手动执行:

java -jar app.jar --spring.config.location=application.properties

And everything works fine, the environment variable is configured as I expected.一切正常,环境变量按照我的预期配置。

Any tips how can I use environment variables in SysV with Spring Boot service?任何提示如何使用 Spring 引导服务在 SysV 中使用环境变量?

are you able to print the variable using echo command?您可以使用 echo 命令打印变量吗?

echo $APP_VERSION

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM