Configured in the previous period springboot A problem in multi environment management , I found a lot of information but didn't give a detailed introduction , Finally, combining with online data to solve , So record it .
First pom build Profiles Corresponding isolation environment name
stay pom In bulid Add to label resources
resources You need to package the configuration files when you package
<resource> <directory>src/main/resources</directory> <!--
Without this properties Can't get it pom Value of --> <filtering>true</filtering> </resource> </resources>
stay resoruce Create the corresponding environment configuration folder in the level directory （ Folder location can be based on resources Self defined configuration of , It doesn't have to be level ）, such as dev/beta/prod
Public documents resources in application.properties When packaging, you need to obtain the configuration of the corresponding environment , join spring.profiles.active=@activatedProperties@ according to maven
profiles Select the corresponding environment to obtain automatically pom The corresponding environment name parameter configured in
application.properties Cannot get pom Value problem of
Configured spring.profiles.active=@activatedProperties@ Cannot get pom Of profiles Value problem , stay pom
resource Add under label <filtering>true</filtering> That's it .
That's the general configuration .