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的用户,讲的只是皮毛,高手请自觉略过 ...
随机推荐
- Linux架构之Nginx 常见问题
第54章 Nginx常见问题 一.Nginx多Sever优先级 在开始处理一个http请求时,nginx会取出header头中的Host变量,与nginx.conf中每个server的server_n ...
- keras数据增强
1.keras数据增强:https://www.cnblogs.com/hutao722/p/10075150.html 2 .keras fit 中的 verbose verbose:日志显示ver ...
- Qt的ui->setupUi(this)在做什么?
ui->setupUi() 新建好Qt的工程之后,总是会在MainWindow函数中有一行代码 ui->setupUi(this); 跟踪进这行代码 class Ui_MainWindow ...
- Java数据封装成树形结构,多级
参考地址:https://blog.csdn.net/chendu500qiang/article/details/91493147 1.实体类 @data public class PublishS ...
- 常用windbg命令(转)
1.查看版本信息:version.vertarget. 2.查看模块信息:lm.!dlls.!lmvi等. 3.调用栈:用k命令显示调用栈,用.frames命令切换栈帧. 4.内存操作:读内存用d命令 ...
- Python(1) 整型与浮动型
整型与浮动型 整数/浮动数=浮点型整数/整数 = 浮点型 例如:>>> type(1/1)<class 'float'>>>> type(1/1.0)& ...
- Django【第10篇】:Django之分页初级版本
分页和中间件 一.分页 Django的分页器(paginator) view.py from django.shortcuts import render,HttpResponse # Create ...
- SpringCloud学习系列-Eureka服务注册与发现(4)
actuator与注册微服务信息完善 1.主机名称:服务名称修改 当前问题 含有主机名称 修改修改microservicecloud-provider-dept-8001 的yml文件 修改内容 eu ...
- sqlserver数据库脱机和分离的区别
脱机和分离的区别: 分离和脱机都可以使数据库不能再被使用,但是分离后需要附加才能使用,而脱机后只需联机就可以用了. 附加数据库报错: 无法打开物理文件 XXX.mdf".操作系统错误 5:& ...
- 【leetcode】1169. Invalid Transactions
题目如下: A transaction is possibly invalid if: the amount exceeds $1000, or; if it occurs within (and i ...