SSM001/构建maven多模块项目
一。Idea构建maven多模块项目
1。创建maven项目--创建父模块
【1】。File->New->Module...

【2】。点击next,填写:GroupId,ArtifactId和Version
注:ArtifactId即为项目名字。

【3】。点击next,添加参数archetypeCatalog=internal(不加该参数,在maven生成骨架时会非常慢)
注:
【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多模块项目的更多相关文章
- Jenkins构建Maven多模块项目时,单独编译子模块,并且不触发构建其它模块
一.Jenkins构建Maven多模块项目时,单独编译子模块 配置: 1.Root POM指向父pom.xml 2.Goals and options指定构建模块的参数:mvn -pl jsoft-w ...
- IntelliJ IDEA 构建maven多模块项目
我们在开发中 因为项目之间需要依赖 所以会在maven创建多个项目配置依赖,这种项目结构主要应用在大型项目中,多人协作开发 1.创建一个项目 File ->NEW -> Projec 2. ...
- maven多模块项目构建
描述 一个大的企业级项目通常跨越了数十万行代码,牵涉了数十或数百软件人员的努力.如果开发者在同一个项目下开 发,那么项目的管理.构建将会变得很难控制.因此设计人员会将项目划分为多个模块,多个模块独 ...
- SpringBoot+Maven 多模块项目的构建、运行、打包
SpringBoot+Maven 多模块项目的构建.运行.打包 https://blog.csdn.net/zekeTao/article/details/79413919
- SpringBoot+Maven 多模块项目的构建、运行、打包实战
前言 最近在做一个很复杂的会员综合线下线上商城大型项目,单模块项目无法满足多人开发和架构,很多模块都是重复的就想到了把模块提出来,做成公共模块,基于maven的多模块项目,也好分工开发,也便于后期微服 ...
- IntelliJ Idea14 创建Maven多模块项目
Maven多模块项目的参考资料 Sonatype上的教程 http://books.sonatype.com/mvnex-book/reference/multimodule.html 在这个教程里, ...
- IntelliJ IDEA中创建Web聚合项目(Maven多模块项目)
Eclipse用多了,IntelliJ中创建Maven聚合项目可能有小伙伴还不太熟悉,我们今天就来看看. IntelliJ中创建普通的Java聚合项目相对来说比较容易,不会涉及到web操作,涉及到we ...
- Maven多模块项目依赖管理
Maven多模块项目依赖管理及dependencies与dependencyManagement的区别 转自:http://blog.csdn.net/liutengteng130/article/d ...
- maven多模块项目,多web合并项目使用心得
Fixflow,做中国最好的开源流程引擎!项目地址https://github.com/fixteam/fixflow 此文章适合maven初学者或想接触maven的用户,讲的只是皮毛,高手请自觉略过 ...
随机推荐
- 011-linux服务管理
linux服务管理 [root@zabbix lianxi]# chkconfig --list 注:该输出结果只显示 SysV 服务,并不包含 原生 systemd 服务.SysV 配置数据 可能被 ...
- Makefile中$$的使用
在linux的Makefile中,经常会见到$var和$$var的形式.下面就这两种表示方法的区别进行简单的概述. 在Makefile中的规则命令行中: $var:将Makefile中的变量var的值 ...
- sys模块-与python解释器交互的模块
需要 import sys a=sys.platform #获取当前系统平台 #如果是window系统就返回‘win32’#如果是linux系统就返回‘linux’#如果是Windows/Cyg ...
- 解决GitHub加载不出图片问题
解决方法: 复制 raw.githubusercontent.com 去 https://www.ipaddress.com 搜索,把给出的IP地址存储到 host 文件中: 如 199.232.28 ...
- UVALive 3263: That Nice Euler Circuit (计算几何)
题目链接 lrj训练指南 P260 //==================================================================== // 此题只需要考虑线 ...
- CSS画心形和蛋形
一.心形 使用transform-origin属性实现设置不同的点为原点 1.改变元素基点transform-origin(transform-origin是变形原点,原点就是元素绕着旋转或变形的点) ...
- k8s登录harbor报错:Error response from daemon: Get https://registry-1.docker.io/v2/: net/http: request cance
[root@k8s-node02 ~]# docker login 192.168.180.105:1180 Username: admin Password: Error response from ...
- Kohana Cache
The default cache group is loaded based on the Cache::$default setting. It is set to the file driver ...
- UOJ418. 【集训队作业2018】三角形
http://uoj.ac/problem/418 题解 考虑激活每个节点时,它的每个儿子都是放满的. 那每一次的操作我们可以用一个二元组来表示\((w_i-\sum w_{son},\sum w_{ ...
- Gradle教程-w3cschool
Gradle,这是一个基于 JVM 的富有突破性构建工具.Gradle 正迅速成为许多开源项目和前沿企业构建系统的选择,同时也在挑战遗留的自动化构建项目.本教程主要讲解了如何使用 Gradle 构建系 ...