1. Separate the configuration files for the development environment, test environment, and production environment, such as:
2. Configure the path of a different environment packaging profile in Maven, configured as follows:
<Profiles> < Profile> <!--Development Environment - <ID>Dev</ID> <Properties> <Env>Dev</Env> </Properties> <activation> <!--the profile node is activated by default - <Activebydefault>True</Activebydefault> </activation> <Build> <Resources> <Resource> <Directory>Src/main/resources-env/dev</Directory> </Resource> <Resource> <Directory>Src/main/resources</Directory> </Resource> </Resources> </Build> </ Profile> < Profile> <!--test Environment - <ID>Qa</ID> <Properties> <Env>Qa</Env> </Properties> <Build> <Resources> <Resource> <Directory>Src/main/resources-env/qa</Directory> </Resource> <Resource> <Directory>Src/main/resources</Directory> </Resource> </Resources> </Build> </ Profile> < Profile> <!--Production Environment - <ID>Online</ID> <Properties> <Env>Online</Env> </Properties> <Build> <Resources> <Resource> <Directory>Src/main/resources-env/online</Directory> </Resource> <Resource> <Directory>Src/main/resources</Directory> </Resource> </Resources> </Build> </ Profile> </Profiles>
3. Configuration before the project is packaged
Right-click the project->maven-> fill in the environment you want to package:
4. Project packaging, when the project is unpacked after the decompression can be seen in the configuration file root directory, you have to package the environment of the configuration files are put in!
Eclipse Maven Profiles Multi-environment configuration, test environment and development environment separately packaged