How to add multiple application.properties files in spring-boot?

前端 未结 4 1282
难免孤独
难免孤独 2020-12-05 02:21

I have a Spring boot application that is divided in several modules. The main module runs the application and has an application.properties file in the resource

4条回答
  •  不思量自难忘°
    2020-12-05 03:02

    What you are trying to do will not work when using Maven or Gradle. The reason is that when the artifact (jar most likely since you are using Spring Boot) is created, there will only be one application.properties file in the root.

    I suggest you either change the name of the properties file on the support module and then configure Spring Boot to look for that file as well (take a look at this or this answer for pointers), or use some kind of merging task for your build tool (something like this perhaps)

提交回复
热议问题