一。Idea构建maven多模块项目

1。创建maven项目--创建父模块

【1】。File->New->Module...

【2】。点击next,填写:GroupId,ArtifactId和Version

注:ArtifactId即为项目名字。

【3】。点击next,添加参数archetypeCatalog=internal(不加该参数,在maven生成骨架时会非常慢)

注:

archetypeCatalog表示插件使用的archetype元数据,不加这个参数时默认为remote,local,即中央仓库archetype元数据,
由于中央仓库的archetype太多了所以导致很慢,指定internal来表示仅使用内部元数据。

【4】点击next,填写module name(模块名称)->finish

【5】。项目结构如下所示:

2。创建module子模块

【1】右击项目-》new Module..

【2】新建Module同1创建父模块。

修改点:

(1)。ArtifactId:ssm-web

(2)。Modual name:ssm-web

最终项目架构如下所示:

3。每个模块中依赖pom.xml配置

maven模块结构图:

---web-ssm

    |--pom.xml(pom)

    |--ssm-web

      |--pom.xml(war)

    |--ssm-service

      |--pom.xml(jar)

    |--ssm-dao

      |--pom.xml(jar)

    |--ssm-model

      |--pom.xml(jar)

注意:括号中标识的是模块的打包(packaging类型)。父项目只能为pom,子项目根据包含内容具体考虑打jar/war包。

maven依赖传递性:

|-ssm-dao模块:负责与数据库交互,持久层。依赖于model层(ssm-model)

ssm-dao->依赖->ssm-model

|-ssm-service模块:负责业务逻辑处理,事务控制层。调用dao传递处理结果。依赖于dao层(ssm-dao)。

而dao依赖于model层。所以service依赖于model层(ssm-model)

ssm-service->依赖->ssm-dao->依赖->ssm-model

|-ssm-web模块:负责与客户端交互,控制层。主要为springmvc的controller类/struts的action类。

依赖于service层。依赖于dao层,依赖于model层。(依赖传递性)

ssm-web->依赖->ssm-service->依赖->ssm-dao->依赖->ssm-model

|-ssm-model模块:独立模块,不依赖于任何其他模块

上述:除非配置了特殊的依赖scope。否则依赖均具有传递性。

【1】。ssm-web子模块

 <?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>web-ssm</artifactId>
<groupId>com.yufeng.web</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>com.yufeng.web</groupId>
<artifactId>ssm-web</artifactId>
<packaging>war</packaging> <name>ssm-web Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- web层添加对model的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-model</artifactId>
<version>${project.version}</version>
</dependency>
<!-- web层添加对service的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-service</artifactId>
<version>${project.version}</version>
</dependency>
<!-- web层添加对dao的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-dao</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> <build>
<finalName>ssm-web</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

【2】。ssm-service子模块

 <?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>web-ssm</artifactId>
<groupId>com.yufeng.web</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>com.yufeng.web</groupId>
<artifactId>ssm-service</artifactId>
<packaging>jar</packaging> <name>ssm-service Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- service层添加对model的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-model</artifactId>
<version>${project.version}</version>
</dependency>
<!-- service层添加对dao的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-dao</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> <build>
<finalName>ssm-service</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

【3】。ssm-dao子模块

 <?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>web-ssm</artifactId>
<groupId>com.yufeng.web</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>com.yufeng.web</groupId>
<artifactId>ssm-dao</artifactId>
<packaging>jar</packaging> <name>ssm-dao Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
<!-- dao层添加对model的依赖-->
<dependency>
<groupId>com.yufeng.web</groupId>
<artifactId>ssm-model</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies> <build>
<finalName>ssm-dao</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

【4】。ssm-model子模块

 <?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/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>web-ssm</artifactId>
<groupId>com.yufeng.web</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion> <groupId>com.yufeng.web</groupId>
<artifactId>ssm-model</artifactId>
<packaging>jar</packaging> <name>ssm-model Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies> <build>
<finalName>ssm-model</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

【5】。web-ssm父模块(聚合子模块modules)

 <?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/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion> <groupId>com.yufeng.web</groupId>
<artifactId>web-ssm</artifactId>
<version>1.0-SNAPSHOT</version>
<!--注意:父模块的packaging是pom ,表示该工程为pom类型。子模块的packaging可以为jar/war-->
<packaging>pom</packaging> <!-- maven聚合,聚合子模块。<module>配置的是子模块的artifactId唯一.-->
<modules>
<module>ssm-web</module>
<module>ssm-service</module>
<module>ssm-dao</module>
<module>ssm-model</module>
</modules> <name>web-ssm Maven Webapp</name>
<!-- FIXME change it to the project's website -->
<url>http://www.example.com</url> <properties>
<!-- 项目统一编码格式-->
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<maven.compiler.source>1.7</maven.compiler.source>
<maven.compiler.target>1.7</maven.compiler.target>
</properties> <dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies> <build>
<finalName>web-ssm</finalName>
<pluginManagement><!-- lock down plugins versions to avoid using Maven defaults (may be moved to parent pom) -->
<plugins>
<plugin>
<artifactId>maven-clean-plugin</artifactId>
<version>3.0.0</version>
</plugin>
<!-- see http://maven.apache.org/ref/current/maven-core/default-bindings.html#Plugin_bindings_for_war_packaging -->
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<version>3.0.2</version>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.20.1</version>
</plugin>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.2.0</version>
</plugin>
<plugin>
<artifactId>maven-install-plugin</artifactId>
<version>2.5.2</version>
</plugin>
<plugin>
<artifactId>maven-deploy-plugin</artifactId>
<version>2.8.2</version>
</plugin>
</plugins>
</pluginManagement>
</build>
</project>

上述:Maven多模块项目已经搭建完成。

下述:整合spring+springmvc+mybatis。

参考网址:http://www.imooc.com/article/19789

SSM001/构建maven多模块项目的更多相关文章

  1. Jenkins构建Maven多模块项目时,单独编译子模块,并且不触发构建其它模块

    一.Jenkins构建Maven多模块项目时,单独编译子模块 配置: 1.Root POM指向父pom.xml 2.Goals and options指定构建模块的参数:mvn -pl jsoft-w ...

  2. IntelliJ IDEA 构建maven多模块项目

    我们在开发中 因为项目之间需要依赖 所以会在maven创建多个项目配置依赖,这种项目结构主要应用在大型项目中,多人协作开发 1.创建一个项目 File ->NEW -> Projec 2. ...

  3. maven多模块项目构建

    描述 一个大的企业级项目通常跨越了数十万行代码,牵涉了数十或数百软件人员的努力.如果开发者在同一个项目下开   发,那么项目的管理.构建将会变得很难控制.因此设计人员会将项目划分为多个模块,多个模块独 ...

  4. SpringBoot+Maven 多模块项目的构建、运行、打包

    SpringBoot+Maven 多模块项目的构建.运行.打包 https://blog.csdn.net/zekeTao/article/details/79413919

  5. SpringBoot+Maven 多模块项目的构建、运行、打包实战

    前言 最近在做一个很复杂的会员综合线下线上商城大型项目,单模块项目无法满足多人开发和架构,很多模块都是重复的就想到了把模块提出来,做成公共模块,基于maven的多模块项目,也好分工开发,也便于后期微服 ...

  6. IntelliJ Idea14 创建Maven多模块项目

    Maven多模块项目的参考资料 Sonatype上的教程 http://books.sonatype.com/mvnex-book/reference/multimodule.html 在这个教程里, ...

  7. IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)

    Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不太熟悉,我们今天就来看看. IntelliJ中创建普通的Java聚合项目相对来说比较容易,不会涉及到web操作,涉及到we ...

  8. Maven多模块项目依赖管理

    Maven多模块项目依赖管理及dependencies与dependencyManagement的区别 转自:http://blog.csdn.net/liutengteng130/article/d ...

  9. maven多模块项目,多web合并项目使用心得

    Fixflow,做中国最好的开源流程引擎!项目地址https://github.com/fixteam/fixflow 此文章适合maven初学者或想接触maven的用户,讲的只是皮毛,高手请自觉略过 ...

随机推荐

  1. elasticsearch——Rest Client

    https://www.jianshu.com/p/66b91bec12e3 elasticsearch——Rest Client 0.2372018.05.10 15:23:03字数 1287阅读 ...

  2. 理解长短期记忆网络(LSTM NetWorks)

    转自:http://www.csdn.net/article/2015-11-25/2826323 原文链接:Understanding LSTM Networks(译者/刘翔宇 审校/赵屹华 责编/ ...

  3. Codeforces 939 时区模拟 三分

    A #include <bits/stdc++.h> #define PI acos(-1.0) #define mem(a,b) memset((a),b,sizeof(a)) #def ...

  4. if_else

    //if.......else if......else //object IF_ELSE {// def main(args:Array[String]){// var x=30// if (x== ...

  5. DevExpress ASP.NET Core Controls 2019发展蓝图(No.5)

    本文主要为大家介绍DevExpress ASP.NET Core Controls 2019年的官方发展蓝图,更多精彩内容欢迎持续收藏关注哦~ [DevExpress ASP.NET Controls ...

  6. ZeroMQ的进阶

    上一篇博文我们对ZeroMQ的经典模式做了写Demo让他跑起来了,但实际开发中我们可能面临一些远比上述复杂的场景.这时候我们需要进一步的对经典模式进行扩展,所幸ZeroMQ已经为我们做好了准备工作. ...

  7. windows及linux下 golang开发环境配置

    windows环境: 1.系统以及软件包版本: OS: windows 8.1  64位  x64处理器 GO:安装包:go1.7.3.windows-amd64.mis IDE:压缩包:liteid ...

  8. Csharp随机生成序列码的方式Guid方法

    主要用于邮箱激活,加密等用处 Guid.NewGuid().ToString()得几种格式显示 .Guid.NewGuid().ToString("N") 结果为: 38bddf4 ...

  9. C++中一些容易迷惑的语法点总结

    #include<iostream> #include<cstring> using namespace std; int main(){ ][]={{,,},{,,}}; ] ...

  10. SSM整合--------试题分析