Maven项目管理工具:MavenProfile精讲

杰米粉2021-10-09 11:32

    一个项目通常都会有多个不同的运行环境,例如开发环境,测试环境、生产环境等。而不同环境的构建过程很可能是不同的,例如数据源配置、插件、以及依赖的版本等。每次将项目部署到不同的环境时,都需要修改相应的配置,这样重复的工作,不仅浪费劳动力,还容易出错。为了解决这一问题,Maven引入了Profile的概念,通过它可以为不同的环境定制不同的构建过程。

    Profile的类型

    Profile可以分为3个类型,它们的作用范围也各不相同。    

类型 位置 有效范围
Per Project Maven 项目的 pom.xml 中 只对当前项目有效
Per User 用户主目录(%USER_HOME%)/.m2/settings.xml 中 对本机上该用户所有 Maven 项目有效
Global Maven 安装目录(%MAVEN_HOME%)/conf/settings.xml 中 对本机上所有 Maven 项目有效

    声明Profile

    Maven通过profiles元素来声明一组Profile配置,该元素下可以包含多个profile子元素,每个profile元素表示一个Profile配置。每个profile元素中通常都要包含一个id子元素,该元素是调用当前Profile的标识。

    定义Profile的一般形式如下:

<profiles>
    <profile>
        <id>profile id</id>
        ....
    </profile>
    <profile>
        <id>profile id</id>
        ....
    </profile>
</profiles>

    除此之外,Profile中还可以声明一些其他的POM元素,但不同位置的Profile所能声明的POM元素也是不同的。

    1.在pom.xml中声明的Profile,由于其能够随着pom.xml一起存在,它被提交到代码仓库中,被Maven安装到本地仓库或远程仓库中,所以它能够修改或增加很多POM元素,其中常用的元素如下表。

一级 二级 三级
project repositories  
pluginRepositories  
dependencies  
plugins  
dependencyManagement  
distributionManagement  
modules  
properties  
reporting  
build plugins
defaultGoal
resources
testResources
directory
filters
finalName
pluginManagement
filters

    2.在setting.xml中声明的Profile是无法保证能够随着pom.xml一起被分发的,因此Maven不允许用户在该类型的Profile修改或增加依赖或插件等配置信息,它只能声明以下范围较为宽泛的元素。

    repositories:仓库配置。

    pluginRepositories:插件仓库配置。

    properties:键值对,该键值对可以在pom.xml中使用。

    激活Profile

    Profile能够在项目构建时,修改POM中配置或者添加一些额外的配置元素。用户可以通过多种方式激活Profile,以实现不同环境使用不同的配置,执行不同的构建过程。

    Profile可以通过以下6种方式激活:

    命令行激活

    settings.xml文件显示激活

    系统属性激活

    操作系统环境激活

    文件存在与否激活

    默认激活

    下面我们以一个Maven项目为例,分别对以上6种激活方式进行介绍。

    准备Maven项目

    1.创建一个名为maven的项目,并在其src/main/resources目录下有3个环境properties配置文件。

    env.properties:默认配置文件

    env.test.properties:测试环境配置文件

    env.prod.properties:生产环境配置文件

    2.该项目目录结构如图所示。Maven项目管理工具:MavenProfile精讲    3.在pom.xml中定义三个不同的Profile,将maven-antrun-plugin:run目标绑定到default生命周期的test阶段上,以实现在不同的Profile中进行不同的操作。

<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 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>net.biancheng.www</groupId>
    <artifactId>maven</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <dependencies>
        <!-- junit依赖 -->
        <dependency>
            <groupId>junit</groupId>
            <artifactId>junit</artifactId>
            <version>4.9</version>
            <scope>compile</scope>
        </dependency>
        <!-- log4j依赖 -->
        <dependency>
            <groupId>log4j</groupId>
            <artifactId>log4j</artifactId>
            <version>1.2.17</version>
        </dependency>
    </dependencies>
    <profiles>
        <!--test 环境配置  -->
        <profile>
            <id>test</id>
            <activation>
                <property>
                    <name>env</name>
                    <value>test</value>
                </property>
            </activation>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <phase>test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <!--输出  -->
                                        <echo>使用 env.test.properties,将其配置信息复制到 D:\eclipse workSpace
                                            3\maven\target\classes\user.properties 中
                                        </echo>
                                        <!-- 在 target\calsses 目录下生成user.properties -->
                                        <!--  env.test.properties 的内容复制到user.properties中-->
                                        <copy file="src/main/resources/env.test.properties"
                                              tofile="${project.build.outputDirectory}/user.properties"/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!-- 默认环境配置 -->
        <profile>
            <id>normal</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <phase>test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>使用 env.properties,将其配置信息复制到 D:\eclipse workSpace
                                            3\maven\target\classes\user.properties 中
                                        </echo>
                                        <!-- 在target\calsses 目录下生成user.properties -->
                                        <!--  env.properties 的内容复制到user.properties中-->
                                        <copy file="src/main/resources/env.properties"
                                              tofile="${project.build.outputDirectory}/user.properties"/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
        <!--生产环境配置  -->
        <profile>
            <id>prod</id>
            <build>
                <plugins>
                    <plugin>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.3</version>
                        <executions>
                            <execution>
                                <phase>test</phase>
                                <goals>
                                    <goal>run</goal>
                                </goals>
                                <configuration>
                                    <tasks>
                                        <echo>使用 env.prod.properties,将其配置信息复制到 D:\eclipse workSpace
                                            3\maven\target\classes\user.properties 中
                                        </echo>
                                        <!-- 在target\calsses 目录下生成user.properties -->
                                        <!--  env.prod.properties 的内容复制到user.properties中-->
                                        <copy file="src/main/resources/env.prod.properties"
                                              tofile="${project.build.outputDirectory}/user.properties"/>
                                    </tasks>
                                </configuration>
                            </execution>
                        </executions>
                    </plugin>
                </plugins>
            </build>
        </profile>
    </profiles>
</project>

    命令行激活

    我们可以在命令行中使用mvn命令行参数-P加上Profile的id来激活Profile,多个id之间使用逗号隔开。例如,激活test1和test2两个Profile,命令如下:

mvn clean install -Ptest1,test2

    打开命令行窗口,跳转到pom.xml所在的目录,执行以下mvn命令,激活id为test的Profile。

mvn clean test -Ptest 

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO] Deleting D:\eclipse workSpace 3\maven\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace 3\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.Test
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用  env.test.properties,将其配置信息复制到 D:\eclipse workSpace 3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace 3\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.968 s
[INFO] Finished at: 2021-03-02T09:28:49+08:00
[INFO] ------------------------------------------------------------------------

  settings.xml文件显示激活

    在本地仓库的settings.xml文件中添加如下配置,激活指定的Profile。

<activeProfiles>
    <activeProfile>test</activeProfile>
</activeProfiles>

    Maven本地仓库的settings.xml文件,默认位于%USER_HOME%/.m2目录下。

    打开命令行窗口,跳转到pom.xml所在的目录下,执行以下mvn命令。

mvn clean test

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO] Deleting D:\eclipse workSpace 3\maven\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace 3\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.Test
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.04 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用  env.test.properties,将其配置信息复制到 D:\eclipse workSpace 3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace 3\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.012 s
[INFO] Finished at: 2021-03-02T09:56:59+08:00
[INFO] ------------------------------------------------------------------------

    系统属性激活

    用户可以配置当某个系统属性存在时,激活指定的Profile。例如,我们在id为prod的profile元素中添加以下配置,表示当系统属性user存在,且值等于prod时,自动激活该Profile。

<activation>
      <property>
        <name>user</name>
        <value>prod</value>
    </property>
</activation>

    打开命令行窗口,跳转到pom.xml所在的目录。执行命令,其中参数-D选项用来指定系统临时属性。

mvn clean test -Duser=prod

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO] Deleting D:\eclipse workSpace 3\maven\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace 3\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.Test
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.039 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用 env.prod.properties,将其配置信息复制到 D:\eclipse workSpace
     [echo]                                                                                     3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace 3\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.036 s
[INFO] Finished at: 2021-03-02T10:23:19+08:00
[INFO] ------------------------------------------------------------------------

    操作系统环境激活

    Maven还可以根据操作系统环境自动激活指定的Profile。例如,将以下配置(本地计算机操作系统环境信息)添加到pom.xml文件中的id为normal的Profile中。

<activation>
    <os>
        <name>Windows 10</name>
        <family>Windows</family>
        <arch>amd64</arch>
        <version>10.0</version>
    </os>
</activation>

        打开命令行窗口,跳转到pom.xml所在的目录下,执行以下mvn命令。

mvn clean test

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO] Deleting D:\eclipse workSpace 3\maven\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (GBK actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding GBK, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace 3\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace 3\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.Test
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.044 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用 env.properties,将其配置信息复制到 D:\eclipse workSpace
     [echo]                                                                                     3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace 3\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.025 s
[INFO] Finished at: 2021-03-02T10:46:12+08:00
[INFO] ------------------------------------------------------------------------

    文件存在与否激活

    Maven可以根据某些文件存在与否,来决定是否激活Profile。例如,在id为prod的Profile中添加以下配置,该配置表示当env.prod.properties文件存在,且env.test.properties文件不存在时,激活该Profile。

<activation>
        <file>
            <exists>./src/main/resources/env.prod.properties</exists>
            <missing>./src/main/resources/env.test.properties</missing>
        </file>
</activation>

    将env.test.properties从项目中删除,打开命令行窗口,跳转到pom.xml所在目录,执行以下命令。

mvn clean test 

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace4\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\eclipse workSpace4\maven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace4\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace4\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.035 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用 env.prod.properties,将其配置信息复制到 D:\eclipse workSpace
     [echo]                                             3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace4\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  2.197 s
[INFO] Finished at: 2021-04-21T15:12:59+08:00
[INFO] ------------------------------------------------------------------------

  默认激活

    我们可以在声明Profile时,指定其默认激活。例如,在id为normal的Profile中添加以下配置,指定该Profile默认激活。

<activation>
    <activeByDefault>true</activeByDefault>
</activation>

    打开命令行窗口,跳转到pom.xml所在目录,执行以下命令。

mvn clean test

    执行结果如下。

[INFO] Scanning for projects...
[INFO]
[INFO] ----------------------< net.biancheng.www:maven >-----------------------
[INFO] Building maven 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ maven ---
[INFO] Deleting D:\eclipse workSpace4\maven\target
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] Copying 2 resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace4\maven\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ maven ---
[WARNING] Using platform encoding (UTF-8 actually) to copy filtered resources, i.e. build is platform dependent!
[INFO] skip non existing resourceDirectory D:\eclipse workSpace4\maven\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ maven ---
[INFO] Changes detected - recompiling the module!
[WARNING] File encoding has not been set, using platform encoding UTF-8, i.e. build is platform dependent!
[INFO] Compiling 1 source file to D:\eclipse workSpace4\maven\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.12.4:test (default-test) @ maven ---
[INFO] Surefire report directory: D:\eclipse workSpace4\maven\target\surefire-reports
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running net.biancheng.www.AppTest
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.038 sec
Results :
Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] --- maven-antrun-plugin:1.3:run (default) @ maven ---
[INFO] Executing tasks
     [echo] 使用 env.prod.properties,将其配置信息复制到 D:\eclipse workSpace
     [echo]                                             3\maven\target\classes\user.properties 中
     [copy] Copying 1 file to D:\eclipse workSpace4\maven\target\classes
[INFO] Executed tasks
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  1.986 s
[INFO] Finished at: 2021-04-21T15:24:59+08:00
[INFO] ------------------------------------------------------------------------

    以上就是小编为大家整理发布的“Maven项目管理工具:MavenProfile精讲”一文,更多相关内容尽在开课吧广场Java教程频道。

Maven项目管理工具:MavenProfile精讲

免责声明:本站所提供的内容均来源于网友提供或网络搜集,由本站编辑整理,仅供个人研究、交流学习使用。如涉及版权问题,请联系本站管理员予以更改或删除。
有用1
分享