I'm running my Spring Boot application with Kubernetes. Part of the architecture involves mounting secrets as file volumes under /opt/config
.
$ ls -l
SECRET_1
SECRET_2
SECRET_3
Each file contains a .properties
like syntax. ( key=value
)
I've been attemtping to make Spring Boot load these as per the documentation spring.config.import=file:/etc/config/myconfig[.yaml]
However I just can't get this to work, my full command is: java -Dspring.config.location=file:./opt/application.properties -Dspring.config.additional-location=file:./opt/config/*[.properties] -jar target/test.war --debug --server.port=8080
The ./opt/application.properties
file is loaded correctly.
I have also attempted to rename all the files to include .properties
:
$ ls -l
SECRET_1.properties
SECRET_2.properties
SECRET_3.properties
And load it via java -Dspring.config.location=file:./opt/application.properties -Dspring.config.import=file:./opt/config/*/ -jar target/test.war --debug --server.port=8080
, however this also did not import any of the properties under ./opt/config
.
I've read through the documentation dozens of times now, and this should be working, but it's not. Did I miss something obvious? Why is it not loading any of the files under ./opt/config
?
I think the problem is that the locations you specify are where spring looks for application.properties, application.yml and profile variants (application-prod.properties, etc). I think you are better off loading all the files in a configured location programmatically, this might provide some ideas.
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.