maven配置多环境
<build> <plugins> <plugin> <groupId>org.springframework.boot</groupId> <artifactId>spring-boot-maven-plugin</artifactId> </plugin> <!-- 配置默认跳过单元测试 结束--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <skip>true</skip> </configuration> </plugin> <!-- 编译 --> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <configuration> <source>1.8</source> <target>1.8</target> <encoding>${project.build.sourceEncoding}</encoding> <compilerArguments> <extdirs>${project.basedir}/lib</extdirs> </compilerArguments> </configuration> </plugin> <!-- 配置多环境--> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-resources-plugin</artifactId> <version>2.5</version> <executions> <execution> <id>copy-resources</id> <phase>compile</phase> <goals> <goal>copy-resources</goal> </goals> <configuration> <overwrite>true</overwrite> <outputDirectory>${project.build.outputDirectory}</outputDirectory> <resources> <resource> <directory>src/main/resources/profiles/${active.profile}</directory> <filtering>false</filtering> </resource> </resources> </configuration> </execution> </executions> </plugin> </plugins> <finalName>DXBChannel</finalName> <!-- 配置资源目录--> <resources> <resource> <directory>src/main/resources</directory> <excludes> <exclude>profiles/*</exclude> </excludes> <!--<filtering>true</filtering>--> </resource> <resource> <directory>src/main/resources</directory> <includes> <include>**/*.xml</include> </includes> </resource> </resources> </build> <!--配置环境的profile--> <profiles> <!--dev默认激活,使用idea Spring Boot 配置启动工程,需要dev的配置--> <profile> <id>dev</id> <properties> <active.profile>dev</active.profile> </properties> <activation> <activeByDefault>true</activeByDefault> </activation> </profile> <profile> <id>test</id> <properties> <active.profile>test</active.profile> </properties> </profile> <profile> <id>prod</id> <properties> <active.profile>prod</active.profile> </properties> </profile> </profiles> </project>
原文地址:https://www.cnblogs.com/zhangshiwen/p/12184797.html
时间: 2024-11-06 21:18:11