I need to load the application.properties file from outside the spring boot war which going to be deployed in tomcat.
I tried various solution missing something
Tried setting environmental variable as below in windows
name : SPRING_CONFIG_NAME value:D:/test/application.properties
i tried multiple values for above value like file:/// in prefix and only file: as perfix .Nothing worked
Tried having context parameter is tomcat like mentioned in below SO answer https://stackoverflow.com/a/44697239/2751962
Tried loading like this in main file which extends SpringBootServletIntializer
protected SpringApplicationBuilder configure(SpringApplicationBuilder application) { return application.sources(Application.class) .properties(getProperties()); }
public static void main(String[] args) throws Exception { SpringApplication.run(Application.class, args); SpringApplicationBuilder springApplicationBuilder = (SpringApplicationBuilder) (new SpringApplicationBuilder(Application.class)) .sources(Application.class) .properties(getProperties()) .run(args); } static Properties getProperties() { Properties props = new Properties(); props.put("spring.config.location", "file:///D:/test/application.properties"); return props; }
I not sure what i missed , Kindly help.