诀情式浮生若梦吧 关注:23贴子:422
  • 13回复贴,共1

【一步一个脚印】Maven 配置文件 pom.xml 详解

只看楼主收藏回复

pom作为项目对象模型。通过xml表示maven项目,使用pom.xml来实现。主要描述了项目:包括配置文件;开发者需要遵循的规则,缺陷管理系统,组织和licenses,项目的url,项目的依赖性,以及其他所有的项目相关因素。


IP属地:浙江1楼2017-03-30 15:36回复
    pom.xml文件:
    <project>
    <parent>
    ...
    </parent>
    <modelVersion>4.0.0</modelVersion>
    <!-- The Basics -->
    <groupId>...</groupId>
    <artifactId>...</artifactId>
    <version>...</version>
    <packaging>...</packaging>
    <scm>
    ...
    </scm>
    <dependencies>
    ...
    </dependencies>
    <dependencyManagement>
    ...
    </dependencyManagement>
    <modules>
    ...
    </modules>
    <properties>
    ...
    </properties>
    <!-- Build Settings -->
    <build>
    ...
    </build>
    <reporting>
    ...
    </reporting>
    <!-- More Project Information -->
    <name>...</name>
    <description>...</description>
    <url>...</url>
    <inceptionYear>...</inceptionYear>
    <licenses>
    </licenses>
    <organization>
    </organization>
    <developers>
    </developers>
    <contributors>
    </contributors>
    <!-- Environment Settings -->
    <issueManagement>
    </issueManagement>
    <ciManagement>
    </ciManagement>
    <mailingLists>
    </mailingLists>
    <prerequisites>
    </prerequisites>
    <repositories>
    </repositories>
    <pluginRepositories>
    </pluginRepositories>
    <distributionManagement>
    </distributionManagement>
    <profiles>
    </profiles>
    </project>


    IP属地:浙江2楼2017-03-30 15:37
    回复
      maven POM.xml 详解:
      <!--父项目的坐标。如果项目中没有规定某个元素的值,那么父项目中的对应值即为项目的默认值。 坐标包括group ID,artifact ID和 version。-->
      <parent>
      <!--被继承的父项目的构件标识符-->
      <artifactId/>
      <!--被继承的父项目的全球唯一标识符-->
      <groupId/>
      <!--被继承的父项目的版本-->
      <version/>
      <!-- 父项目的pom.xml文件的相对路径。相对路径允许你选择一个不同的路径。默认值是../pom.xml。Maven首先在构建当前项目的地方寻找父项 目的pom,其次在文件系统的这个位置(relativePath位置),然后在本地仓库,最后在远程仓库寻找父项目的pom。-->
      <relativePath/>
      </parent>


      IP属地:浙江3楼2017-03-30 15:50
      回复
        <!--声明项目描述符遵循哪一个POM模型版本。模型本身的版本很少改变,虽然如此,但它仍然是必不可少的,这是为了当Maven引入了新的特性或者其他模型变更的时候,确保稳定性。-->
        <modelVersion>4.0.0</modelVersion>
        <!--项目的全球唯一标识符,通常使用全限定的包名区分该项目和其他项目。并且构建时生成的路径也是由此生成, 如com.mycompany.app生成的相对路径为:/com/mycompany/app-->
        <groupId>asia.banseon</groupId>
        <!-- 构件的标识符,它和group ID一起唯一标识一个构件。换句话说,你不能有两个不同的项目拥有同样的artifact ID和groupID;在某个 特定的group ID下,artifact ID也必须是唯一的。构件是项目产生的或使用的一个东西,Maven为项目产生的构件包括:JARs,源 码,二进制发布和WARs等。-->
        <artifactId>banseon-maven2</artifactId>
        <!--项目产生的构件类型,例如jar、war、ear、pom。插件可以创建他们自己的构件类型,所以前面列的不是全部构件类型-->
        <packaging>jar</packaging>
        <!--项目当前版本,格式为:主版本.次版本.增量版本-限定版本号-->
        <version>1.0-SNAPSHOT</version>
        <!--项目的名称, Maven产生的文档用-->
        <name>banseon-maven</name>
        <!--项目主页的URL, Maven产生的文档用-->
        <url>http://www.baidu.com/banseon</url>
        <!-- 项目的详细描述, Maven 产生的文档用。 当这个元素能够用HTML格式描述时(例如,CDATA中的文本会被解析器忽略,就可以包含HTML标 签), 不鼓励使用纯文本描述。如果你需要修改产生的web站点的索引页面,你应该修改你自己的索引页文件,而不是调整这里的文档。-->
        <description>A maven project to study maven.</description>
        <!--描述了这个项目构建环境中的前提条件。-->
        <prerequisites>
        <!--构建该项目或使用该插件所需要的Maven的最低版本-->
        <maven/>
        </prerequisites>


        IP属地:浙江4楼2017-03-30 15:51
        回复
          <!--项目的问题管理系统(Bugzilla, Jira, Scarab,或任何你喜欢的问题管理系统)的名称和URL,本例为 jira-->
          <issueManagement>
          <!--问题管理系统(例如jira)的名字,-->
          <system>jira</system>
          <!--该项目使用的问题管理系统的URL-->
          <url>http://jira.baidu.com/banseon</url>
          </issueManagement>
          <!--项目持续集成信息-->
          <ciManagement>
          <!--持续集成系统的名字,例如continuum-->
          <system/>
          <!--该项目使用的持续集成系统的URL(如果持续集成系统有web接口的话)。-->
          <url/>
          <!--构建完成时,需要通知的开发者/用户的配置项。包括被通知者信息和通知条件(错误,失败,成功,警告)-->
          <notifiers>
          <!--配置一种方式,当构建中断时,以该方式通知用户/开发者-->
          <notifier>
          <!--传送通知的途径-->
          <type/>
          <!--发生错误时是否通知-->
          <sendOnError/>
          <!--构建失败时是否通知-->
          <sendOnFailure/>
          <!--构建成功时是否通知-->
          <sendOnSuccess/>
          <!--发生警告时是否通知-->
          <sendOnWarning/>
          <!--不赞成使用。通知发送到哪里-->
          <address/>
          <!--扩展配置项-->
          <configuration/>
          </notifier>
          </notifiers>
          </ciManagement>


          IP属地:浙江5楼2017-03-30 15:52
          回复
            <!--项目创建年份,4位数字。当产生版权信息时需要使用这个值。-->
            <inceptionYear/>
            <!--项目相关邮件列表信息-->
            <mailingLists>
            <!--该元素描述了项目相关的所有邮件列表。自动产生的网站引用这些信息。-->
            <mailingList>
            <!--邮件的名称-->
            <name>Demo</name>
            <!--发送邮件的地址或链接,如果是邮件地址,创建文档时,mailto: 链接会被自动创建-->
            <post>banseon@126.com</post>
            <!--订阅邮件的地址或链接,如果是邮件地址,创建文档时,mailto: 链接会被自动创建-->
            <subscribe>banseon@126.com</subscribe>
            <!--取消订阅邮件的地址或链接,如果是邮件地址,创建文档时,mailto: 链接会被自动创建-->
            <unsubscribe>banseon@126.com</unsubscribe>
            <!--你可以浏览邮件信息的URL-->
            <archive>http:/hi.baidu.com/banseon/demo/dev/</archive>
            </mailingList>
            </mailingLists>


            IP属地:浙江6楼2017-03-30 15:53
            回复
              <!--项目开发者列表-->
              <developers>
              <!--某个项目开发者的信息-->
              <developer>
              <!--SCM里项目开发者的唯一标识符-->
              <id>HELLO WORLD</id>
              <!--项目开发者的全名-->
              <name>banseon</name>
              <!--项目开发者的email-->
              <email>banseon@126.com</email>
              <!--项目开发者的主页的URL-->
              <url/>
              <!--项目开发者在项目中扮演的角色,角色元素描述了各种角色-->
              <roles>
              <role>Project Manager</role>
              <role>Architect</role>
              </roles>
              <!--项目开发者所属组织-->
              <organization>demo</organization>
              <!--项目开发者所属组织的URL-->
              <organizationUrl>http://hi.baidu.com/banseon</organizationUrl>
              <!--项目开发者属性,如即时消息如何处理等-->
              <properties>
              <dept>No</dept>
              </properties>
              <!--项目开发者所在时区, -11到12范围内的整数。-->
              <timezone>-5</timezone>
              </developer>
              </developers>
              <!--项目的其他贡献者列表-->
              <contributors>
              <!--项目的其他贡献者。参见developers/developer元素-->
              <contributor>
              <name/><email/><url/><organization/><organizationUrl/><roles/><timezone/><properties/>
              </contributor>
              </contributors>


              IP属地:浙江7楼2017-03-30 15:53
              回复
                <!--该元素描述了项目所有License列表。 应该只列出该项目的license列表,不要列出依赖项目的 license列表。如果列出多个license,用户可以选择它们中的一个而不是接受所有license。-->
                <licenses>
                <!--描述了项目的license,用于生成项目的web站点的license页面,其他一些报表和validation也会用到该元素。-->
                <license>
                <!--license用于法律上的名称-->
                <name>Apache 2</name>
                <!--官方的license正文页面的URL-->
                <url>http://www.baidu.com/banseon/LICENSE-2.0.txt</url>
                <!--项目分发的主要方式:
                repo,可以从Maven库下载
                manual, 用户必须手动下载和安装依赖-->
                <distribution>repo</distribution>
                <!--关于license的补充信息-->
                <comments>A business-friendly OSS license</comments>
                </license>
                </licenses>
                <!--SCM(Source Control Management)标签允许你配置你的代码库,供Maven web站点和其它插件使用。-->
                <scm>
                <!--SCM的URL,该URL描述了版本库和如何连接到版本库。欲知详情,请看SCMs提供的URL格式和列表。该连接只读。-->
                <connection>
                scm:svn:http://svn.baidu.com/banseon/maven/banseon/banseon-maven2-trunk(dao-trunk)
                </connection>
                <!--给开发者使用的,类似connection元素。即该连接不仅仅只读-->
                <developerConnection>
                scm:svn:http://svn.baidu.com/banseon/maven/banseon/dao-trunk
                </developerConnection>
                <!--当前代码的标签,在开发阶段默认为HEAD-->
                <tag/>
                <!--指向项目的可浏览SCM库(例如ViewVC或者Fisheye)的URL。-->
                <url>http://svn.baidu.com/banseon</url>
                </scm>


                IP属地:浙江8楼2017-03-30 15:54
                回复
                  <!--描述项目所属组织的各种属性。Maven产生的文档用-->
                  <organization>
                  <!--组织的全名-->
                  <name>demo</name>
                  <!--组织主页的URL-->
                  <url>http://www.baidu.com/banseon</url>
                  </organization>
                  <!--构建项目需要的信息-->
                  <build>
                  <!--该元素设置了项目源码目录,当构建项目的时候,构建系统会编译目录里的源码。该路径是相对于pom.xml的相对路径。-->
                  <sourceDirectory/>
                  <!--该元素设置了项目脚本源码目录,该目录和源码目录不同:绝大多数情况下,该目录下的内容 会被拷贝到输出目录(因为脚本是被解释的,而不是被编译的)。-->
                  <scriptSourceDirectory/>
                  <!--该元素设置了项目单元测试使用的源码目录,当测试项目的时候,构建系统会编译目录里的源码。该路径是相对于pom.xml的相对路径。-->
                  <testSourceDirectory/>
                  <!--被编译过的应用程序class文件存放的目录。-->
                  <outputDirectory/>
                  <!--被编译过的测试class文件存放的目录。-->
                  <testOutputDirectory/>
                  <!--使用来自该项目的一系列构建扩展-->
                  <extensions>
                  <!--描述使用到的构建扩展。-->
                  <extension>
                  <!--构建扩展的groupId-->
                  <groupId/>
                  <!--构建扩展的artifactId-->
                  <artifactId/>
                  <!--构建扩展的版本-->
                  <version/>
                  </extension>
                  </extensions>
                  <!--当项目没有规定目标(Maven2 叫做阶段)时的默认值-->
                  <defaultGoal/>
                  <!--这个元素描述了项目相关的所有资源路径列表,例如和项目相关的属性文件,这些资源被包含在最终的打包文件里。-->
                  <resources>
                  <!--这个元素描述了项目相关或测试相关的所有资源路径-->
                  <resource>
                  <!-- 描述了资源的目标路径。该路径相对target/classes目录(例如${project.build.outputDirectory})。举个例 子,如果你想资源在特定的包里(org.apache.maven.messages),你就必须该元素设置为org/apache/maven /messages。然而,如果你只是想把资源放到源码目录结构里,就不需要该配置。-->
                  <targetPath/>
                  <!--是否使用参数值代替参数名。参数值取自properties元素或者文件里配置的属性,文件在filters元素里列出。-->
                  <filtering/>
                  <!--描述存放资源的目录,该路径相对POM路径-->
                  <directory/>
                  <!--包含的模式列表,例如**/*.xml.-->
                  <includes/>
                  <!--排除的模式列表,例如**/*.xml-->
                  <excludes/>
                  </resource>
                  </resources>
                  <!--这个元素描述了单元测试相关的所有资源路径,例如和单元测试相关的属性文件。-->
                  <testResources>
                  <!--这个元素描述了测试相关的所有资源路径,参见build/resources/resource元素的说明-->
                  <testResource>
                  <targetPath/><filtering/><directory/><includes/><excludes/>
                  </testResource>
                  </testResources>
                  <!--构建产生的所有文件存放的目录-->
                  <directory/>
                  <!--产生的构件的文件名,默认值是${artifactId}-${version}。-->
                  <finalName/>
                  <!--当filtering开关打开时,使用到的过滤器属性文件列表-->
                  <filters/>
                  <!--子项目可以引用的默认插件信息。该插件配置项直到被引用时才会被解析或绑定到生命周期。给定插件的任何本地配置都会覆盖这里的配置-->
                  <pluginManagement>
                  <!--使用的插件列表 。-->
                  <plugins>
                  <!--plugin元素包含描述插件所需要的信息。-->
                  <plugin>
                  <!--插件在仓库里的group ID-->
                  <groupId/>
                  <!--插件在仓库里的artifact ID-->
                  <artifactId/>
                  <!--被使用的插件的版本(或版本范围)-->
                  <version/>
                  <!--是否从该插件下载Maven扩展(例如打包和类型处理器),由于性能原因,只有在真需要下载时,该元素才被设置成enabled。-->
                  <extensions/>
                  <!--在构建生命周期中执行一组目标的配置。每个目标可能有不同的配置。-->
                  <executions>
                  <!--execution元素包含了插件执行需要的信息-->
                  <execution>
                  <!--执行目标的标识符,用于标识构建过程中的目标,或者匹配继承过程中需要合并的执行目标-->
                  <id/>
                  <!--绑定了目标的构建生命周期阶段,如果省略,目标会被绑定到源数据里配置的默认阶段-->
                  <phase/>
                  <!--配置的执行目标-->
                  <goals/>
                  <!--配置是否被传播到子POM-->
                  <inherited/>
                  <!--作为DOM对象的配置-->
                  <configuration/>
                  </execution>
                  </executions>
                  <!--项目引入插件所需要的额外依赖-->
                  <dependencies>
                  <!--参见dependencies/dependency元素-->
                  <dependency>
                  ......
                  </dependency>
                  </dependencies>
                  <!--任何配置是否被传播到子项目-->
                  <inherited/>
                  <!--作为DOM对象的配置-->
                  <configuration/>
                  </plugin>
                  </plugins>
                  </pluginManagement>


                  IP属地:浙江9楼2017-03-30 15:55
                  回复
                    maven的协作相关属性
                    <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/maven-v4_0_0.xsd">
                    <modelVersion>4.0.0</modelVersion>
                    <groupId>org.codehaus.mojo</groupId>
                    <artifactId>my-project</artifactId>
                    <version>1.0</version>
                    <packaging>war</packaging>
                    </project>
                    groupId : 组织标识,例如:org.codehaus.mojo,在M2_REPO目录下,将是: org/codehaus/mojo目录。
                    artifactId : 项目名称,例如:my-project,在M2_REPO目录下,将是:org/codehaus/mojo/my-project目录。
                    version : 版本号,例如:1.0,在M2_REPO目录下,将是:org/codehaus/mojo/my-project/1.0目录。
                    packaging : 打包的格式,可以为:pom , jar , maven-plugin , ejb , war , ear , rar , par


                    IP属地:浙江10楼2017-03-30 16:06
                    回复
                      POM之间的关系
                      主要用于POM文件的复用。
                      依赖关系:依赖关系列表(dependency list)是POM的重要部分。
                      <dependencies>
                      <dependency>
                      <groupId>junit</groupId>
                      <artifactId>junit</artifactId>
                      <version>4.0</version>
                      <scope>test</scope>
                      </dependency>

                      </dependencies>
                      groupId , artifactId , version :
                      scope : compile(default),provided,runtime,test,system
                      exclusions


                      IP属地:浙江11楼2017-03-30 16:06
                      回复
                        继承关系:继承其他pom.xml配置的机制。
                        比如父pom.xml:
                        <project>
                        [...]
                        <dependencies>
                        <dependency>
                        <groupId>junit</groupId>
                        <artifactId>junit</artifactId>
                        <version>4.4</version>
                        <scope>test</scope>
                        </dependency>
                        </dependencies>
                        [...]
                        </project>
                        在子pom.xml文件继承它的依赖(还可以继承其他的:developers and contributors、plugin lists、reports lists、plugin executions with matching ids、plugin configuration):
                        [...]
                        <parent>
                        <groupId>com.devzuz.mvnbook.proficio</groupId>
                        <artifactId>proficio</artifactId>
                        <version>1.0-SNAPSHOT</version>
                        </parent>
                        [...]
                        在这种机制下,maven还提供了一个类似Java.lang.Object的顶级父pom.xml文件:
                        <project>
                        <modelVersion>4.0.0</modelVersion>
                        <name>Maven Default Project</name>
                        <repositories>
                        <repository>
                        <id>central</id>
                        <name>Maven Repository Switchboard</name>
                        <layout>default</layout>
                        <url>http://repo1.maven.org/maven2</url>
                        <snapshots>
                        <enabled>false</enabled>
                        </snapshots>
                        </repository>
                        </repositories>
                        <pluginRepositories>
                        <pluginRepository>
                        <id>central</id>
                        <name>Maven Plugin Repository</name>
                        <url>http://repo1.maven.org/maven2</url>
                        <layout>default</layout>
                        <snapshots>
                        <enabled>false</enabled>
                        </snapshots>
                        <releases>
                        <updatePolicy>never</updatePolicy>
                        </releases>
                        </pluginRepository>
                        </pluginRepositories>
                        <build>
                        <directory>target</directory>
                        <outputDirectory>target/classes</outputDirectory>
                        <finalName>${project.artifactId}-${project.version}</finalName>
                        <testOutputDirectory>target/test-classes</testOutputDirectory>
                        <sourceDirectory>src/main/java</sourceDirectory>
                        <scriptSourceDirectory>src/main/scripts</scriptSourceDirectory>
                        <testSourceDirectory>src/test/java</testSourceDirectory>
                        <resources>
                        <resource>
                        <directory>src/main/resources</directory>
                        </resource>
                        </resources>
                        <testResources>
                        <testResource>
                        <directory>src/test/resources</directory>
                        </testResource>
                        </testResources>
                        <pluginManagement>
                        <plugins>
                        <plugin>
                        <artifactId>maven-antrun-plugin</artifactId>
                        <version>1.1</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-assembly-plugin</artifactId>
                        <version>2.2-beta-2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-clean-plugin</artifactId>
                        <version>2.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-compiler-plugin</artifactId>
                        <version>2.0.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-dependency-plugin</artifactId>
                        <version>2.0</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <version>2.3</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-ear-plugin</artifactId>
                        <version>2.3.1</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-ejb-plugin</artifactId>
                        <version>2.1</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-install-plugin</artifactId>
                        <version>2.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-jar-plugin</artifactId>
                        <version>2.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <version>2.4</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-plugin-plugin</artifactId>
                        <version>2.4.1</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-rar-plugin</artifactId>
                        <version>2.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-release-plugin</artifactId>
                        <version>2.0-beta-7</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-resources-plugin</artifactId>
                        <version>2.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-site-plugin</artifactId>
                        <version>2.0-beta-6</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-source-plugin</artifactId>
                        <version>2.0.4</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-surefire-plugin</artifactId>
                        <version>2.4.2</version>
                        </plugin>
                        <plugin>
                        <artifactId>maven-war-plugin</artifactId>
                        <version>2.1-alpha-1</version>
                        </plugin>
                        </plugins>
                        </pluginManagement>
                        </build>
                        <reporting>
                        <outputDirectory>target/site</outputDirectory>
                        </reporting>
                        <profiles>
                        <profile>
                        <id>release-profile</id>
                        <activation>
                        <property>
                        <name>performRelease</name>
                        <value>true</value>
                        </property>
                        </activation>
                        <build>
                        <plugins>
                        <plugin>
                        <inherited>true</inherited>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-source-plugin</artifactId>
                        <executions>
                        <execution>
                        <id>attach-sources</id>
                        <goals>
                        <goal>jar</goal>
                        </goals>
                        </execution>
                        </executions>
                        </plugin>
                        <plugin>
                        <inherited>true</inherited>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-javadoc-plugin</artifactId>
                        <executions>
                        <execution>
                        <id>attach-javadocs</id>
                        <goals>
                        <goal>jar</goal>
                        </goals>
                        </execution>
                        </executions>
                        </plugin>
                        <plugin>
                        <inherited>true</inherited>
                        <groupId>org.apache.maven.plugins</groupId>
                        <artifactId>maven-deploy-plugin</artifactId>
                        <configuration>
                        <updateReleaseInfo>true</updateReleaseInfo>
                        </configuration>
                        </plugin>
                        </plugins>
                        </build>
                        </profile>
                        </profiles>
                        </project>
                        可以通过下面命令查看当前pom.xml受到超pom.xml文件的影响:
                        mvn help:effective-pom


                        IP属地:浙江12楼2017-03-30 16:06
                        回复
                          聚合关系:用于将多个maven项目聚合为一个大的项目。
                          <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/maven-v4_0_0.xsd">
                          <modelVersion>4.0.0</modelVersion>
                          <groupId>org.codehaus.mojo</groupId>
                          <artifactId>my-parent</artifactId>
                          <version>2.0</version>
                          <modules>
                          <module>my-project<module>
                          </modules>
                          </project>
                          属性
                          maven的属性,是值的占位符,类似EL,类似ant的属性,比如${X},可用于pom文件任何赋值的位置。有以下分类:
                          env.X:操作系统环境变量,比如${env.PATH}
                          project.x:pom文件中的属性,比如:<project><version>1.0</version></project>,引用方式:${project.version}
                          settings.x:settings.xml文件中的属性,比如:<settings><offline>false</offline></settings>,引用方式:${settings.offline}
                          Java System Properties:java.lang.System.getProperties()中的属性,比如java.home,引用方式:${java.home}
                          自定义:在pom文件中可以:<properties><installDir>c:/apps/cargo-installs</installDir></properties>,引用方式:${installDir}


                          IP属地:浙江13楼2017-03-30 16:07
                          回复
                            构建设置
                            构建有两种build标签:
                            <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/maven-v4_0_0.xsd">

                            <!– "Project Build" contains more elements than just the BaseBuild set –>
                            <build>…</build>
                            <profiles>
                            <profile>
                            <!– "Profile Build" contains a subset of "Project Build"s elements –>
                            <build>…</build>
                            </profile>
                            </profiles>
                            </project>
                            build中的主要标签:Resources和Plugins。
                            Resources:用于排除或包含某些资源文件
                            <resources>
                            <resource>
                            <targetPath>META-INF/plexus</targetPath>
                            <filtering>false</filtering>
                            <directory>${basedir}/src/main/plexus</directory>
                            <includes>
                            <include>configuration.xml</include>
                            </includes>
                            <excludes>
                            <exclude>**/*.properties</exclude>
                            </excludes>
                            </resource>
                            </resources>
                            Plugins:设置构建的插件
                            <build>

                            <plugins>
                            <plugin>
                            <groupId>org.apache.maven.plugins</groupId>
                            <artifactId>maven-jar-plugin</artifactId>
                            <version>2.0</version>
                            <extensions>false</extensions>
                            <inherited>true</inherited>
                            <configuration>
                            <classifier>test</classifier>
                            </configuration>
                            <dependencies>…</dependencies>
                            <executions>…</executions>
                            </plugin>


                            IP属地:浙江14楼2017-03-30 16:07
                            回复