简体   繁体   中英

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.

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:

app.info.version=${APP_VERSION}

I always execute export APP_VERSION=1 before start my service but ${APP_VERSION} is always empty. 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?

are you able to print the variable using echo command?

echo $APP_VERSION

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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