How can I override Spring Boot application.properties programmatically?

后端 未结 10 1721
失恋的感觉
失恋的感觉 2020-11-29 18:33

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

10条回答
  •  旧时难觅i
    2020-11-29 19:02

    This is how you can override the application.properties programatically if you have to.

    public static void main(String[] args) {
        SpringApplication app = new SpringApplication(Restdemo1Application.class);
        app.setAdditionalProfiles("dev"); 
        // overrides "application.properties" with  "application-dev.properties"
        app.run(args);
    
    }
    

提交回复
热议问题