Skip to content
Advertisement

`spring.config.location` is ignored

Fairly straight forward. I have a configuration file:

# ls -la /etc/my-application
-rwxr-xr-x 1 root root 18 May  3 04:24 /etc/my-application
# cat /etc/my-application
server.port=12345

I run my application as a follows:

java org.springframework.boot.loader.JarLauncher --spring.config.location="file:///etc/my-application"

And logging indicates the setting is visible to the application:

04:28:16.919 [main] WARNING CONFIG- [–spring.config.location=file:///etc/my-application]

But my settings are ignored:

Tomcat initialized with port(s): 8080 (http)

The following yields the same outcome:

java org.springframework.boot.loader.JarLauncher --spring.config.location="file://etc/my-application"

So does:

java org.springframework.boot.loader.JarLauncher --spring.config.location="file:/etc/my-application"

This doesn’t work either, the arguments don’t come through as well:

java -Dspring.config.location="file:///etc/my-application" org.springframework.boot.loader.JarLauncher
...
... 04:36:53.979 [main] WARNING CONFIG - []

Curiously enough if I specify the setting directly, it works:

java org.springframework.boot.loader.JarLauncher --server.port=12345
...
... Tomcat initialized with port(s): 12345 (http)

Where am I going wrong with this? Tearing my hair out over this one!

Advertisement

Answer

The winning combination turned out be:

java org.springframework.boot.loader.JarLauncher --spring.config.location=file:///etc/resources-master-server.properties

The key point here is that extension matters. Spring appears to determine what the settings file is by the extension, rather than the contents of the file and without the extension it didn’t seem to know what to do with the properties file.

Thankyou to those who chipped in for their help and suggestions, Sameer twigged me as to what the issue may be.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement