I have an internal application.yml configuration file located in the resources folder on classpath.
I have an external configuration file: /home/username/config.properties which overrides some fields to run in a server context.
I want the fields in the external config file to override internal file and retain the fields in the internal file if not defined in external file.
The answers suggested Spring - how to override internal config file with external file doesn't work.
For example, the following command doesn't works for me:
java -jar application.jar --spring.config.location=classpath:/,file:///home/minister/config.properties
How do I achieve this desired outcome?
EDIT: This issue only happens on Linux. When I run it with the overriden configuration file on my Windows 10 machine, it works properly.
看起来您有太多/
,请尝试:
java -jar application.jar --spring.config.location=classpath:/,file:/home/minister/config.properties
You can pass the path to file, relative to the .jar file, for example,
java -jar application.jar -Dspring.config.location=./config/application.properties
or
java -jar application.jar -Dspring.config.location=../common/config
either of these work. Please refer - Spring Documentation for further details on how externalized configuration works.
Hope this helps.
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.