为什么要重构呢? 因为经过观察发现80工程和8001工程下的实体类和统一返回类出现重复,为了避免新建重复的实体类,所以我们需要重构
新建cloud-api-commons模块用于存储相同的实体类代码,和统一使用的工具类
<?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>springcloud</artifactId>
<groupId>com.dance</groupId>
<version>1.0-SNAPSHOT</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>cloud-api-commons</artifactId>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId>
<scope>runtime</scope>
<optional>true</optional>
</dependency>
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<optional>true</optional>
</dependency>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>5.1.0</version>
</dependency>
</dependencies>
</project>将com.dance.springcloud.entities包中的内容全部移动到新建cloud-api-commons工程下,并创建同样的包
因为在公共工程下已经存在了
添加Maven坐标 修改80和8001工程的pom.xml文件,增加依赖
<!-- dependent on common modules -->
<dependency>
<groupId>com.dance</groupId>
<artifactId>cloud-api-commons</artifactId>
<version>1.0-SNAPSHOT</version>
</dependency>重新编译Maven,即可 作者:彼岸舞 时间:2021\08\16 内容关于:Spring Cloud H版 本文属于作者原创,未经允许,禁止转发