第4章 商品微服務搭建
1. 服務搭建
在
thankson-springcloud-provider
子產品下添加
thankson-springcloud-mall-api
和
thankson-springcloud-mall-service
1.1 pom.xml配置
1、修改provider子產品的pom.xml
<?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>changgou</artifactId>
<groupId>com.thankson.springcloud</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>thankson-springcloud-provider</artifactId>
<packaging>pom</packaging>
<modules>
<module>thankson-springcloud-fastdfs</module>
<module>thankson-springcloud-mall-api</module>
<module>thankson-springcloud-mall-service</module>
</modules>
<dependencies>
<dependency>
<groupId>com.thankson.springcloud</groupId>
<artifactId>thankson-common-component</artifactId>
<version>1.0.0</version>
</dependency>
<!--eureka用戶端-->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<!--fastJSON-->
<dependency>
<groupId>com.alibaba</groupId>
<artifactId>fastjson</artifactId>
<version>${fastjson.version}</version>
</dependency>
<!--lombok-->
<dependency>
<groupId>org.projectlombok</groupId>
<artifactId>lombok</artifactId>
<version>${lombok.version}</version>
<scope>provided</scope>
</dependency>
</dependencies>
</project>
2、修改api子產品的pom.xml
<?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>thankson-springcloud-provider</artifactId>
<groupId>com.thankson.springcloud</groupId>
<version>1.0.0</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>thankson-springcloud-mall-api</artifactId>
<packaging>pom</packaging>
<modules>
<module>thankson-springcloud-mall-api-goods</module>
</modules>
<dependencies>
<dependency>
<groupId>javax.persistence</groupId>
<artifactId>persistence-api</artifactId>
<version>${persistence.version}</version>
<scope>compile</scope>
</dependency>
</dependencies>
</project>
1.2 建立商品微服務
在
thankson-springcloud-mall-service
子產品下建立
thankson-springcloud-mall-service-goods
微服務
在
thankson-springcloud-mall-api
子產品下建立
thankson-springcloud-mall-api-goods
微服務
結構如下
![](https://img.laitimes.com/img/__Qf2AjLwojIjJCLyojI0JCLiAzNfRHLGZkRGZkRfJ3bs92YsYTMfVmepNHLycGVNlXTE90dRpHW4Z0MMBjVtJWd0ckW65UbM5WOHJWa5kHT20ESjBjUIF2X0hXZ0xCMx81dvRWYoNHLrdEZwZ1Rh5WNXp1bwNjW1ZUba9VZwlHdssmch1mclRXY39CXldWYtlWPzNXZj9mcw1ycz9WL49zZuBnLyAzNxMDO1MjM2ATNwAjMwIzLc52YucWbp5GZzNmLn9Gbi1yZtl2Lc9CX6MHc0RHaiojIsJye.png)
1.3 業務代碼
thankson-springcloud-mall-service-goods
微服務與
thankson-springcloud-mall-api-goods
微服務的結構如下
因采用代碼生成器直接生成,故不進行講解
代碼生成器下載下傳
2. 結束語
至此,商品微服務的基本代碼已經開發完畢。後續會在使用的時候進行優化處理
- Github位址:https://github.com/Thankson2020/SpringCloud-ChangGou
- 碼雲位址:https://gitee.com/thankson2020/SpringCloud-ChangGou