Project development requires multiple environments, which are generally development, testing, pre-release, and formal. maven can be used to package and deploy projects in different environments. The command is: in mvn package-P dev, "dev" is the environment variable id, which can be defined by myself. The name I defined is dev, qa, pre, prod, which is specific in pom. the configuration in xml is as follows: [html] <? Xml version = "1.0" encoding = "UTF-8"?> <Project xmlns = "http://maven.apache.org/POM/4.0.0" xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance" xsi: schemaLocation = "http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd"> ...... <profiles> <profile> <id> dev </id> <properties> <env> dev </env> </properties> <activation> <activeByDefault> true </activeByDefault> </activation> </profile> <id> qa </id> <properties> <env> qa </env> </properties> </profile> <profile> <id> pre </id> <properties> <env> pre </env> </properties> </profile> <id> prod </id> <properties> <env> prod </env> </properties> </profile> </profiles> ...... <build> <filters> <filter> config/$ {env }. properties </filter> </filters> <resources> <resource> <directory> src/main/resources </directory> <filtering> true </filtering> </resource> www.2cto.com </resources> ...... </build> </project> 1. profiles defines the address of the variable configuration file in id2.filters of each environment. The environment variable in the address is the value defined in profile above 3. resources defines the directories under which files will be replaced by the variables defined in the configuration file. Generally, we will place the project configuration file under src/main/resources, such as db, bean, the variables used in the package will be replaced with fixed values according to the variable configuration in the filter.