Using Environment Variables with SysV Centos6

147 Views Asked by At

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 ?

1

There are 1 best solutions below

1
On

are you able to print the variable using echo command?

echo $APP_VERSION