mattm
mattm

Reputation: 5949

How do I set Spring Boot environment variables in Upstart to override application.properties?

I have a Spring Boot project that has a series of configuration variables in application.properties. For example:

server.ssl.enabled = false
server.port = 8080

I would like to move these variables into an upstart script, where they will be loaded into environment variables and override the contents of the application.properties file.

This is my attempt to load these in the upstart conf file:

env server.ssl.enabled=false
env server.port=8080

The init-checkconf /etc/init/my-example.conf utility to check the upstart configuration file produces the following error, with the first error on the line for server.ssl.enabled: ERROR: File /etc/init/my-example.conf: syntax invalid: init:my-example.conf:15: Unexpected token

What is the proper syntax to set these variables in upstart, with the names used in the application.properties file? All of the upstart examples I have found use names that do not include the character ..

Upvotes: 1

Views: 2472

Answers (1)

Kartik Pandya
Kartik Pandya

Reputation: 2898

Replace the dots in the property names with underscores. Spring Boot will cover it for you. Case doesn't matter.

You can also pass the properties as command line arguments such as:

$ java -jar app.jar --foo.bar="splat"

Upvotes: 2

Related Questions