In microservice projects, many duplicate entity classes, public methods, static variables and the like cannot be avoided. We need to build a public module to remove code redundancy
-
Step 1: Create a new module and select the maven project (right-click the parent project gulimall—select New—select Module)
-
Step 2: Configure pom.xml (import public dependencies), public methods
-
Step 3: install
-
Step 4: Introduce common modules into other microservices
<!--提取的公共包-->
<dependency>
<groupId>com.atguigu.gulimall</groupId>
<artifactId>gulimall-common</artifactId>
<version>0.0.1-SNAPSHOT</version>
</dependency>