I have jdbc property files which I take from external configuration web-service In spring boot in order to set mysql props it\'s easy as adding those to application.properti
Just to provide another option to this thread for reference as when I started to look for an answer for my requirement this came high on the search list, but did not cover my use case.
I was looking to programmatically set spring boot property at start up, but without the need to work with the different XML/Config files that spring supports.
The easiest way is to set the properties at the time the SpringApplication is defined. The basic example below sets the tomcat port to 9999.
@SpringBootApplication
public class Demo40Application{
public static void main(String[] args){
SpringApplication application = new SpringApplication(Demo40Application.class);
Properties properties = new Properties();
properties.put("server.port", 9999);
application.setDefaultProperties(properties);
application.run(args);
}
}