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
<resources> <resource>
<directory>src/main/resources.${activatedProperties}</directory> </resource>
<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 .

 

Technology
©2019-2020 Toolsou All rights reserved,
Solve in servlet The Chinese output in is a question mark C String function and character function in language MySQL management 35 A small coup optimization Java performance —— Concise article Seven sorting algorithms (java code ) use Ansible Batch deployment SSH Password free login to remote host according to excel generate create Build table SQL sentence Spring Source code series ( sixteen )Spring merge BeanDefinition Principle of Virtual machine installation Linux course What are the common exception classes ?