I have server.yml file that contains Spring Framework only properties like port number, context root path, application name.
And, I have a applicationContext.xml that has the following:
<util:properties id="springProperties" location="classpath*:my.properties"> <context:property-placeholder location="classpath*:my.properties" local-override="true" properties-ref="springProperties" /> my.properties file resides in src/main/resources dir of the project.
So then, I can access properties from my java classes like:
@Autowired @Qualifier("springProperties") private Properties props; public String getProperty(String key){ return props.getProperty(key); } or like `${my.prop}` When I build war and run Spring Boot (java -jar server.war), internal my.properties resolves, and everything works as expected.
However, I wanted to override that file with the external my.properties. I read https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html
I tried to run something like:
java -jar server.jar --spring.config.location=classpath:/my.properties or
java -jar server.jar --spring.config.location=my.properties
But the only properties I can override by this are from my server.yml. Meaning, I can override port number, or application name. But the internal my.properties is never affected.
Am I doing something wrong? I understand that external my.property simply should be in a classpath, then it overrides internal my.property. But it never happens.
springPropertiesfor this configuration. The copy ofmy.propertiesyou are loading externally likely is not affecting that context.