<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>${st.groupId}</groupId>
<artifactId>${st-common-parent.name}</artifactId>
<version>${st-common-parent.version}</version>
<relativePath>../st-common-parent</relativePath>
</parent>
<artifactId>${st-common-config.name}</artifactId>
<version>${st-common-config.version}</version>
<description>公共配置(配置工程)</description>
<!--配置需要的环境文件-->
<profiles>
<profile>
<id>localTest</id>
<activation>
<!--默认选择当前环境-->
<activeByDefault>true</activeByDefault>
</activation>
<build>
<resources>
<!--需要引入的资源文件-->
<resource>
<directory>deployEnv/localTest</directory>
<targetPath>${project.build.directory}/classes</targetPath>
<filtering>true</filtering>
</resource>
</resources>
</build>
</profile>
</profiles>
<!--默认打包配置-->
<build>
<finalName>${st-common-config.name}</finalName>
<resources>
<resource>
<directory>src/main/resources</directory>
<targetPath>${project.build.directory}/classes</targetPath>
<includes>
<include>**/*</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
</build>
</project>
这里的profile和Spring里面的profile是一样的道理,
首先对默认的文件进行打包,然后读取默认激活的profile或者通过参数指定的profile进行文件的添加和替换。
打包命令
指定激活的profile进行打包mvn package -P localTest
使用默认激活的profile mvn package
同名文件会被替换掉
网友评论