Spring Boot Inherit application.properties from dependency

后端 未结 2 998
面向向阳花
面向向阳花 2020-12-01 09:25

Let\'s say I have 5 Spring Boot Projects. All of them have a Maven dependency on a Spring Boot project No 6 with some shared/common classes. 5 independent projects have a lo

2条回答
  •  一向
    一向 (楼主)
    2020-12-01 09:58

    Use PropertySource annotation and provide two sources for your app:

    @PropertySources({
            @PropertySource("classpath:app-common.properties"),
            @PropertySource("classpath:app.properties")
        })
    

    more details can be found there https://docs.spring.io/spring-boot/docs/current/reference/html/boot-features-external-config.html

提交回复
热议问题