How can I override Spring Boot application.properties programmatically?

后端 未结 10 1733
失恋的感觉
失恋的感觉 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条回答
  •  余生分开走
    2020-11-29 19:10

    Since spring boot 1.3 EnvironmentPostProcessor is available for this purpose. Create a subclass of it and register in META-INF/spring.factories A good example is here :

    https://github.com/spring-cloud/spring-cloud-sleuth/blob/48f3f9783f277a795d0210399f0ea09b7f1a4e71/spring-cloud-sleuth-core/src/main/java/org/springframework/cloud/sleuth/autoconfig/TraceEnvironmentPostProcessor.java

提交回复
热议问题