接上篇,創建 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類型 。 如下圖: