maven多环境配置
在src/main/resources目录下分别建各个环境的文件夹,然后对应修改pom.xml:
<build> <resources> <resource> <directory>src/main/resources/${env}</directory> </resource> <resource> <directory>src/main/resources</directory> <excludes> <exclude>dev/*</exclude> <exclude>test/*</exclude> <exclude>prod/*</exclude> </excludes> </resource> </resources> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> </plugins>
</build>
<profiles> <profile> <id>dev</id> <properties> <env>dev</env> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <env>test</env> </properties> </profile> <profile> <id>prod</id> <properties> <env>prod</env> </properties> </profile> </profiles>
打包命令:mvn clean package -Dmaven.test.skip=true -P test