I want to load properties file that is outside the springboot app and override the sprignboot matched application properties on the run time environment Programmatically not through server context/ runtime args?
I have found a way to implement this by creating listener for ApplicationEnvironmentPreparedEvent. working code example link: https://www.programcreek.com/java-api-examples/index.php?api=org.springframework.core.env.ConfigurableEnvironment
But looking for much more easy and spring boot managed solution
something like this (below code is not working though) :
SpringApplication application = new SpringApplication(MainApplication.class);
application.setBannerMode(Mode.OFF);
Properties props = new Properties();
try{
props.load(newFileInputStream(
"C:\\...\\PropFile\\applicationconfig.properties"));
application.setDefaultProperties(props);
application.run(args);
} catch (Exception e) {
//print exception here;
}