maven 父子关系模块配置(二)--子模块配置

接上篇,创建 jar 类型子模块 。 

step1:  

  eclipse中 File->new->other -> maven project ->next

step2:

  一直next 到下面这个界面

   

 step 3: 继续next 

 

step 4: 点击finish 。 创建后的son-one pom文件如下:

step 5: 修改pom文件 

  1. 添加 

   <parent>

    <groupId>test-parent-module</groupId>

    <artifactId>parent</artifactId>

    <version>0.0.1-SNAPSHOT</version>

  </parent>

 其中 groupId  和 artifactId 分别为为上篇中创建的父模块的 groupId  和 artifactId

  2. 删除

    删除son-one中 的 groupId  和 version 。 因为配置了parent 以后  子模块会自动继承父模块的groupId  和 version

  修改后的pom文件如下:

 

<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>test-parent-module</groupId>

    <artifactId>parent</artifactId>

    <version>0.0.1-SNAPSHOT</version>

  </parent>

 

  <artifactId>son-one</artifactId>

  <packaging>jar</packaging>

 

  <name>son-one</name>

  <url>http://maven.apache.org</url>

 

  <properties>

    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>

  </properties>

 

  <dependencies>

    <dependency>

      <groupId>junit</groupId>

      <artifactId>junit</artifactId>

      <version>3.8.1</version>

      <scope>test</scope>

    </dependency>

  </dependencies>

</project>

=========================================================

war类型子模块创建:

  war类型子模块创建和jar类型差不多。  只是在上面step2 里选择 webapp类型 。 如下图:

 

posted @ 2015-12-08 21:44  T+++  阅读(5315)  评论(0编辑  收藏  举报