springboot+maven打包,项目中经常用到不同的环境下打包不同的配置文件,比如连接的数据库、配置文件、日志文件级别等都不一样。
在pom.xml文件中定义
<project>
<dependencies>
</dependencies>
<profiles>
<profile>
<id>dev</id>
<activation>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<deploy.type>dev</deploy.type>
</properties>
</profile>
<profile>
<id>prod</id>
<properties>
<deploy.type>prod</deploy.type>
</properties>
</profile>
</profiles>
<build>
<resources>
<resource>
<directory>src/main/profiles/${deploy.type}</directory>
</resource>
<resource>
<directory>src/main/resources/</directory>
</resource>
<resource>
<directory>src/main/java</directory>
<includes>
<include>**/*.xml</include>
</includes>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>8</source>
<target>8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
重点是这行代码,结合maven就能打包不同的文件夹。
<resource>
<directory>src/main/profiles/${deploy.type}</directory>
</resource>
需要打包那个环境的,打钩后双击就可以了。
原文:https://www.cnblogs.com/ruanjianlaowang/p/11182698.html