2
votes

I have followed instructions from spring-boot documentation and successfully deployed spring-boot as service in centos.

All the following commands work

sudo /etc/init.d/myapp start
sudo /etc/init.d/myapp stop
sudo /etc/init.d/myapp status

application.properties has database credentials that I need to override during deployment. I want to set it as RUN_ARGS environment variable simply because my CI server (Jenkins) will be deploying the app, setting up environment variable and start the service

so I was hoping the following that the following two commands will work in my centos machine

export RUN_ARGS='spring.datasource.username=XXXXX,spring.datasource.password=YYYY'
sudo /etc/init.d/myapp start

However, these two values are not picked up spring boot app. It rather takes default values in application.properties and the service fails when initializing the pool.

what is wrong with the way I am passing the RUN_ARGS. what is the correct way to do it?

I also tried using JAVA_OPTS but of no use.

export JAVA_OPTS='-Dspring.datasource.username=XXXXX,-Dspring.datasource.password=YYYY'
sudo /etc/init.d/myapp start
1

1 Answers

2
votes

If I remember correctly it should be

 sudo /etc/init.d/myapp start --spring.datasource.username=xxx --spring.datasource.password=yyy