【Maven】工程中可能用到的pom.xml

父工程的pom.xml中可能存在的标签

 

<!-- 指定打包类型,如果打包类型为jar,可以省略不指定,如果为war或者是pom,必须显示指定 -->

  <packaging>pom</packaging>

 

  <!-- 依赖的管理--子工程中都要使用到的jar包 【1】-->

  <dependencyManagement>

       <dependencies>

                <dependency>

                         <groupId>junit</groupId>

                            <artifactId>junit</artifactId>

                            <version>4.9</version>

                            <scope>test</scope>

                </dependency>

       </dependencies>

  </dependencyManagement>

 

  <!-- 聚合 -->

  <modules>

       <module>../MakeFriend</module>

       <module>../HelloFriend</module>

       <module>../OurFriend</module>

       <module>../Hello</module>

  </modules>

子工程的pom.xml中可能会用到标签

<!-- 模块版本 -->

         <modelVersion>4.0.0</modelVersion>

        

         <!-- 坐标 -->

         <!-- <groupId>com.test.maven</groupId> -->

         <artifactId>HelloFriend</artifactId>

         <!-- <version>0.0.1-SNAPSHOT</version> -->

        

         <!-- 模块名/ 项目名/ 工程名 -->

         <name>Hello</name>

        

         <!-- 继承【1】 要先声明继承-->

         <parent>

                   <groupId>com.test.maven</groupId>

                <artifactId>Parent</artifactId>

                <version>0.0.1-SNAPSHOT</version>

<!-- 指定从当前子工程的pom.xml文件出发,查找父工程的pom.xml的路径 -->

                   <relativePath>../Parent/pom.xml</relativePath>

         </parent>

         <!-- jar包的依赖 【1】继承父工程的jar包,可省略groupId和version -->

         <dependencies>

                   <!-- Junit  -->

                   <dependency>

                            <groupId>junit</groupId>

                            <artifactId>junit</artifactId>

                            <!-- <version>4.0</version> -->

                            <scope>test</scope>

                   </dependency>

 

<!—HelloFriend依赖Hello,排除其中的一些依赖 -->

                   <dependency>

                                     <!-- 依赖的另一个工程-->

                                     <groupId>com.test.maven</groupId>

                                     <artifactId>Hello</artifactId>

                                     <version>0.0.1-SNAPSHOT</version>

                                     <scope>compile</scope>

                                     <!-- 依赖的排除 -->

                                     <exclusions>

                                               <exclusion>

                                                        <groupId>commons-logging</groupId>

                                                        <artifactId>commons-logging</artifactId>

                                               </exclusion>

                                               <exclusion>

                                                        <groupId>org.springframework</groupId>

                                                    <artifactId>spring-core</artifactId>

                                               </exclusion>

                                     </exclusions>

                            </dependency>

                   <!-- log4j -->

                   <dependency>

                            <groupId>log4j</groupId>

                            <artifactId>log4j</artifactId>

                            <version>1.2.17</version>

                            <scope>compile</scope>

                   </dependency>

 

                   <!-- 声明配置【2】 -->

             <properties>

                   <!-- 定义表示spring版本的变量 -->

                      <spring-version>4.0.0.RELEASE</spring-version>

            </properties>

                   <!-- Spring-core  【2】-->

                   <dependency>

                      <groupId>org.springframework</groupId>

                      <artifactId>spring-core</artifactId>

                      <version>${spring-version}</version>

                   </dependency>

</dependencies>

        

         <build>

                   <plugins>

                   <!-- 解决maven test命令时console出现中文乱码乱码 -->

                            <plugin>

                            <groupId>org.apache.maven.plugins</groupId>

                            <artifactId>maven-surefire-plugin</artifactId>

                            <version>2.7.2</version>

                            <configuration>

                                     <forkMode>once</forkMode><!--在一个进程中进行所有测试 ; 默认值:once -->

                                     <argLine>-Dfile.encoding=UTF-8</argLine>

                            </configuration>

                            </plugin>

                   </plugins>

         </build>

 
 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值