简介
通过Maven创建的多模块项目。
模块是此POM列出并作为一组执行的项目。通过一个pom打包的项目可以将它们列为模块来聚合成一组项目进行构建,这些模块名是这些项目的相对目录。
Maven项目之间不仅存在多模块的聚合关系,而且Maven项目之间还可以存在相互继承的关系,子模块将继承父模块的一些配置和引用的jar,子模块无需另外引用。,属性元素包括:
- groupId
- version
- description
- url
- inceptionYear
- organization
- licenses
- developers
- contributors
- mailingLists
- scm
- issueManagement
- ciManagement
- properties
- dependencyManagement
- dependencies
- repositories
- pluginRepositories
- build
- plugin executions with matching ids
- plugin configuration
- etc.
- reporting
- profiles
当然有些属性是不能被继承的- artifactId
- name
- prerequisites
而且模块之间可以项目引用。
虽然多模块(聚合)通常伴随着父POM的继承关系,但是这两者不是必须同时存在的,任何项目都可以继承这个父POM。
项目创建
父项目创建
src目录在这里是可删除的
模块Service创建
模块Web创建
一、二步骤同上
四、五步骤同上
<dependency>
<groupId>com.bigbigbu</groupId>
<artifactId>big-service</artifactId>
<version>${project.version}</version>
</dependency>
接下来搭建框架开发即可。(注意模块引用后,编译打包需现在Demo编译打包后,再在WEB项目上进行编译打包,避免引用子模块包非最新)