多工程Maven工程的创建

来源:互联网 发布:零基础学大数据算法pdf 编辑:程序博客网 时间:2024/05/13 05:33
1、创建顶层的mvn工程的pom.xml
<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>
<name>Centrepoint</name>
<groupId>com.effectivemaven.centrepoint</groupId>
<artifactId>centrepoint</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<description>
Centrepoint is a basic but useful application that sets up a
dashboard of project information from Maven, Archiva and
Continuum.
</description>
</project>

2 假设我们要创建的工程包括3个模块   module-one,module-two,module-three
依次执行下面的语句
mvn archetype:generate -DartifactId=module-one -DgroupId=com.maventest.parent
mvn archetype:generate -DartifactId=module-two -DgroupId=com.maventest.parent
mvn archetype:generate -DartifactId=module-three -DgroupId=com.maventest.parent

3 执行完成之后 mvn eclipse:eclipse 导入工程就会得到3个工程

4 查看主pom.xml 可以看到已经变成
<?xml version="1.0" encoding="UTF-8"?>
<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>
<name>parent</name>
<groupId>com.maventest.parent</groupId>
<artifactId>projectMain</artifactId>
<packaging>pom</packaging>
<version>1.0-SNAPSHOT</version>
<description>
This is main parent project.
</description>
<modules>
<module>module-one</module>
<module>module-two</module>
<module>module-three</module>
<module>module-web</module>
</modules>
</project>

5 增加本地repository
<repositories>
<repository>
<id>holly-thinkpad-releases</id>
<name>holly-thinkpad-releases</name>
<url>http://localhost:8081/artifactory/repo</url>
</repository>
</repositories>


6 增加dependencies
<dependencies>

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${spring.maven.artifact.version}</version>
</dependency>
</dependencies>

7 增加resource 文件路径
<build>
<resources>
<!-- standard Maven folder -->
<resource>
<directory>src/main/resources</directory>
</resource>
<!-- plus root folder -->
<resource>
<directory>.</directory>
<includes>
<include>plugin.xml</include>
<include>META-INF/*</include>
</includes>
</resource>
</resources>
</build>

原创粉丝点击