I have an internal application.yml file located in the classpath resources with the following fields:
redis:
hostname: localhost
port: 6379
database: 0
password:
There is an external config file: config.properties. It defines some fields to be overridden in my server context. File config.properties:
redis.hostname = db.example.com
redis.password = my_password
The application fails to start because it is not able to read the redis.port property in the config file. My doubt is that spring is not retaining fields of a property source(redis) completely if it has already found some fields defined in the external file(hostname, password in this case).
I am running the application using the following command:
java -jar -Dspring.config.location=file:///home/username/config.properties application.jar
How do I make spring properly override the internal configuration file so that it only overrides the extra properties(redis.hostname, redis.password) but still retain the other fields defined in the internal file(like redis.port, redis.database) but not defined in the external file?
P.S: I know this is what is happening because when I add the redis.port=6379 property in the external config file, the applications works properly.