springboot项目maven配置多环境
Posted 得意莫骄傲,失意莫沮丧。
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了springboot项目maven配置多环境相关的知识,希望对你有一定的参考价值。
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>
以上是关于springboot项目maven配置多环境的主要内容,如果未能解决你的问题,请参考以下文章
springboot+maven项目使用 profiles 配置多环境
SpringBoot使用profile结合maven实现多环境配置
三十二张图告诉你,Jenkins构建SpringBoot有多简单~
springboot配置文件application-dev.properties,application-prod.properties,application-test.properties(代码片