Spring Boot 快速上手(10)Maven聚合工程
架构场景
简单场景:电商系统

一套电商系统需要包含前台后台两套系统,此时,部分工具类和,持久层的代码是一样的,为了提高系统复用,采用maven 聚合工程的方式构建最合适不过了。
创建Maven 项目
新建maven父工程,删除src目录,在聚合工程中多模块,父工程仅作为模块即管理,场景通用,前台,后台模块,配置pom
创建模块:项目名字右键添加模块,创建maven项目

配置pom,自己创建的common通用模块会被其他两个模块使用,也要添加到依赖管理中
<?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>
<packaging>pom</packaging>
<modules>
<module>common</module>
<module>front</module>
<module>back</module>
</modules>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.6.2</version>
</parent>
<groupId>org.example</groupId>
<artifactId>maven-demo-1</artifactId>
<version>1.0-SNAPSHOT</version>
<properties>
<maven.compiler.source>8</maven.compiler.source>
<maven.compiler.target>8</maven.compiler.target>
<mybatis-plus.version>3.4.2</mybatis-plus.version>
<mybatis-plus-generator.version>3.4.1</mybatis-plus-generator.version>
<druid.version>1.2.6</druid.version>
<freemarker.version>2.3.30</freemarker.version>
</properties>
<dependencyManagement>
<dependencies>
<!-- 自己创建通用模块也需要管理 -->
<dependency>
<groupId>org.example</groupId>
<artifactId>common</artifactId>
<version>${project.version}
SpringBoot Maven聚合工程实战

最低0.47元/天 解锁文章
3151

被折叠的 条评论
为什么被折叠?



