使用Maven构建多模块企业项目

首先,前面几次学习已经学会了安装maven,如何创建maven项目等,最近的学习,终于有点进展了,搭建一下企业级多模块项目。

好了,废话不多说,具体如下:

首先新建一个maven项目,pom.xml的文件如下:

 1 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 2     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
 3     <modelVersion>4.0.0</modelVersion>
 4     <groupId>com.mi</groupId>
 5     <artifactId>note</artifactId>
 6     <!-- 搭建多模块项目,必须要有一个packaging为pom的根目录 -->
 7     <packaging>pom</packaging>
 8     <version>0.0.1-SNAPSHOT</version>
 9     <name>note Maven Webapp</name>
10     <url>http://maven.apache.org</url>
11     
12     <dependencies>
13         <dependency>
14             <groupId>junit</groupId>
15             <artifactId>junit</artifactId>
16             <version>3.8.1</version>
17             <scope>test</scope>
18         </dependency>
19 
20         <dependency>
21             <groupId>jstl</groupId>
22             <artifactId>jstl</artifactId>
23             <version>1.2</version>
24         </dependency>
25 
26         <dependency>
27             <groupId>taglibs</groupId>
28             <artifactId>standard</artifactId>
29             <version>1.1.2</version>
30         </dependency>
31 
32         <dependency>
33             <groupId>org.springframework</groupId>
34             <artifactId>spring-test</artifactId>
35             <version>4.2.5.RELEASE</version>
36         </dependency>
37 
38     </dependencies>
39     <build>
40         <finalName>note</finalName>
41         <plugins>
42             <plugin>
43                 <groupId>org.codehaus.cargo</groupId>
44                 <artifactId>cargo-maven2-plugin</artifactId>
45                 <version>1.2.3</version>
46                 <configuration>
47                     <container>
48                         指明使用的tomcat服务器版本
49                         <containerId>tomcat7x</containerId>
50                         指明tomcat服务器的安装目录
51                         <home>C:/Program Files/Apache Tomcat 7.0</home>
52                     </container>
53                     <configuration>
54                         <type>existing</type>
55                         指明tomcat服务器的安装目录
56                         <home>C:/Program Files/Apache Tomcat 7.0</home>
57                     </configuration>
58                 </configuration>
59                 <executions>
60                     <execution>
61                         <id>cargo-run</id>
62                         <phase>install</phase>
63                         <goals>
64                             <goal>run</goal>
65                         </goals>
66                     </execution>
67                 </executions>
68             </plugin>
69         </plugins>
70 
71     </build>
72     <modules>
73         <module>note-user</module>
74     </modules>
75 </project>

搭建多模块项目,必须要有一个packaging为pom的根目录。创建好这个maven项目后,我们对着项目右键-->new

和建立web的maven项目一样,不在重复,finish完成;目录如下:

参考:http://www.cnblogs.com/quanyongan/archive/2013/05/28/3103243.html

原文地址:https://www.cnblogs.com/tingbogiu/p/5443683.html