终于来到了后端路线的尽头–微服务 三年,你知道我这三年是怎么过的吗?! 大一:html+css+js+Java基础 大二:Java高级+Java8—>Mysql—>JDBC—>数据结构与算法—>JavaWeb—>Spring5—> SpringMVC—>MyBatis—>MyBatisPlus—>Maven—>SpringBoot—>Git—>Linux—> —>设计模式 大三:Redis—>RabbitMQ—>Nginx—>Netty—>Dubbo—>SpringCloud—>Eureka—> Zookeeper—>Consul—>Ribbon—>Hystrix—>Gateway—>config—>Bus—>Stream —>Sleuth—>SpringAlibaba—>Nacos—>Sentinel—>Seata 终于有点要摸到终点线的感觉了o(╥﹏╥)o 什么是微服务
微服务是一种架构风格
一个应用拆分为一组小型服务
每个服务运行在自己的进程内,也就是可独立部署和升级
服务之间使用轻量级HTTP交互
服务围绕业务功能拆分
可以由全自动部署机制独立部署
去中心化,服务自治。服务可以使用不同的语言、不同的存储技术
分布式微服务架构-落地维度
服务调用
服务降级
服务注册与发现
服务熔断
负载均衡
服务消息队列
服务网关
配置中心管理
自动化构建部署
服务监控
全链路追踪
服务定时任务
调度操作
Spring Cloud简介 SpringCloud=分布式微服务架构的站式解决方案,是多种微服务架构落地技术的集合体,俗称微服务全家桶 关于微服务主要是跟着尚硅谷周阳老师的视频学习 Spring Cloud技术栈
springcloud搭建项目选用的技术栈
在搭建微服务架构的时候一定是约定 > 配置 > 编码 创建微服务cloud整体聚合父工程Project,有8个关键步骤:
New Project - maven工程 - create from archetype: maven-archetype-site
聚合总父工程名字
Maven选版本
工程名字
字符编码 - Settings - File encoding
注解生效激活 - Settings - Annotation Processors
Java编译版本选8
File Type过滤 - Settings - File Type
从刚开始创建工程就遇到了问题 在新建模块的时候8001和8002建成了8081和8082,学到zookeeper才反应过来,只是模块名不同其余内容都一样 问题1:maven版本不对应,maven3.8和idea2021不兼容 解决方法:重新下载maven3.5.4版本 问题2:pom文件的依赖项爆红 解决方法:查看maven仓库位置是否正确,清除idea的缓存并重启 问题3:mysql版本问题,要求至少是5.7我在导入的时候看到自己是5.1.49 以为自己版本过低又下了一个Java8的版本,后来才发现mysql5.7的版本号是5.1.47,自己的版本还高两个 问题4:老师是用${mysql.version}来指定版本号的,我也这么写后idea爆红,找不到依赖项 解决方法:配置环境变量或手动指定版本号 问题5:我在引入依赖项的时候,复制了别人写好的笔记,导致多引入了两个依赖项Zipkin和netflix,刚开始我写完代码运行后报错一直不知道问题出在哪,后来查了好久才知道是多引入了包导致的 解决方法:我来来回回重建了好几次项目都不行,直到把依赖从pom中去掉然后把在maven中包删除后清除idea缓存重启才行了 设置好后的父pom文件 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 <?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 > <groupId > com.wzg.springcloud</groupId > <artifactId > cloud2022</artifactId > <version > 1.0-SNAPSHOT</version > <modules > <module > provider-payment8081</module > <module > consumer-order80</module > <module > api-commons</module > </modules > <packaging > pom</packaging > <properties > <project.build.sourceEncoding > UTF-8</project.build.sourceEncoding > <maven.compiler.source > 1.8</maven.compiler.source > <maven.compiler.target > 1.8</maven.compiler.target > <junit.version > 4.12</junit.version > <log4j.version > 1.2.17</log4j.version > <lombok.version > 1.18.16</lombok.version > <mysql.version > 5.1.49</mysql.version > <druid.version > 1.1.17</druid.version > <mybatis.spring.boot.version > 2.1.4</mybatis.spring.boot.version > </properties > <dependencyManagement > <dependencies > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-dependencies</artifactId > <version > 2.2.2.RELEASE</version > <type > pom</type > <scope > import</scope > </dependency > <dependency > <groupId > org.springframework.cloud</groupId > <artifactId > spring-cloud-dependencies</artifactId > <version > Hoxton.SR1</version > <type > pom</type > <scope > import</scope > </dependency > <dependency > <groupId > com.alibaba.cloud</groupId > <artifactId > spring-cloud-alibaba-dependencies</artifactId > <version > 2.1.0.RELEASE</version > <type > pom</type > <scope > import</scope > </dependency > <dependency > <groupId > mysql</groupId > <artifactId > mysql-connector-java</artifactId > <version > 5.1.49</version > </dependency > <dependency > <groupId > com.alibaba</groupId > <artifactId > druid</artifactId > <version > 1.1.17</version > </dependency > <dependency > <groupId > junit</groupId > <artifactId > junit</artifactId > <version > ${junit.version}</version > </dependency > <dependency > <groupId > log4j</groupId > <artifactId > log4j</artifactId > <version > ${log4j.version}</version > </dependency > <dependency > <groupId > org.mybatis.spring.boot</groupId > <artifactId > mybatis-spring-boot-starter</artifactId > <version > 2.1.4</version > </dependency > <dependency > <groupId > org.projectlombok</groupId > <artifactId > lombok</artifactId > <version > 1.18.16</version > <optional > true</optional > </dependency > </dependencies > </dependencyManagement > <build > <plugins > <plugin > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-maven-plugin</artifactId > <version > 2.7.1</version > <configuration > <fork > true</fork > <addResources > true</addResources > </configuration > </plugin > </plugins > </build > </project >
复习DependencyManagement和Dependencies Maven使用dependencyManagement
元素来提供了一种管理依赖版本号的方式。
通常会在一个组织或者项目的最顶层的父POM中看到dependencyManagement
元素。
使用pom.xml中的dependencyManagement
元素能让所有在子项目中引用个依赖而不用显式的列出版本量。
Maven会沿着父子层次向上走,直到找到一个拥有dependencyManagement
元素的项目,然后它就会使用这个
dependencyManagement
元素中指定的版本号。
1 2 3 4 5 6 7 8 9 <dependencyManagement > <dependencies > <dependency > <groupId > mysq1</groupId > <artifactId > mysql-connector-java</artifactId > <version > 5.1.2</version > </dependency > <dependencies > </dependencyManagement >
然后在子项目里就可以添加mysql-connector
时可以不指定版本号,例如:
1 2 3 4 5 6 <dependencies > <dependency > <groupId > mysq1</groupId > <artifactId > mysql-connector-java</artifactId > </dependency > </dependencies >
这样做的好处 就是:如果有多个子项目都引用同一样依赖,则可以避免在每个使用的子项目里都声明一个版本号,这样当想升级或切换到另一个版本时,只需要在顶层父容器里更新,而不需要一个一个子项目的修改;另外如果某个子项目需要另外的一个版本,只需要声明version就可。
dependencyManagement
里只是声明依赖,并不实现引入 ,因此子项目需要显示的声明需要用的依赖 。
如果不在子项目中声明依赖,是不会从父项目中继承下来的;只有在子项目中写了该依赖项,并且没有指定具体版本,才会从父项目中继承该项,并且version和scope都读取自父pom。
如果子项目中指定了版本号,那么会使用子项目中指定的jar版本。
IDEA右侧旁的Maven插件有Toggle ' Skip Tests' Mode
按钮,这样maven可以跳过单元测试
父工程创建完成执行mvn : install
将父工程发布到仓库方便子工程继承。
支付模块构建 创建微服务模块套路:
建Module
改POM
写YML
主启动
业务类
创建cloud-provider-payment8001微服务提供者支付Module模块:
1.建名为provider-payment8001的Maven工程
2.改POM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 <?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 > cloud2022</artifactId > <groupId > com.wzg.springcloud</groupId > <version > 1.0-SNAPSHOT</version > </parent > <modelVersion > 4.0.0</modelVersion > <artifactId > provider-payment8081</artifactId > <dependencies > <dependency > <artifactId > api-commons</artifactId > <groupId > com.wzg.springcloud</groupId > <version > 1.0-SNAPSHOT</version > </dependency > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-starter-web</artifactId > </dependency > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-starter-actuator</artifactId > </dependency > <dependency > <groupId > org.mybatis.spring.boot</groupId > <artifactId > mybatis-spring-boot-starter</artifactId > </dependency > <dependency > <groupId > com.alibaba</groupId > <artifactId > druid-spring-boot-starter</artifactId > <version > 1.1.10</version > </dependency > <dependency > <groupId > mysql</groupId > <artifactId > mysql-connector-java</artifactId > </dependency > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-starter-jdbc</artifactId > </dependency > <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 > org.springframework.boot</groupId > <artifactId > spring-boot-starter-test</artifactId > <scope > test</scope > </dependency > </dependencies > <properties > <maven.compiler.source > 8</maven.compiler.source > <maven.compiler.target > 8</maven.compiler.target > </properties > </project >
解决方法:移除该插件或在yml文件中手动指定端口号 3.写YML
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 server: port: 8001 spring: application: name: cloud-provider-service datasource: type: com.alibaba.druid.pool.DruidDataSource #当前数据源操作类型 driver-class-name: org.gjt.mm.mysql.Driver #mysql驱动包 # driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql: username: root password: 123 druid: test-while -idle: true validation-query: SELECT 1 #eureka: # client: # register-with-eureka: false # 是否注册自己的信息到EurekaServer,默认是true # fetch-registry: false # 是否拉取其它服务的信息,默认是true # service-url: # EurekaServer的地址,现在是自己的地址,如果是集群,需要加上其它Server的地址。 # defaultZone: http: mybatis: mapper-locations: classpath:mapper
问题7:项目运行时会报Error: testWhileIdle is true, validationQuery not set的错误。空闲的时候需要进行检测,但是检测的查询语句没有设置。大致意思就是说,当数据库没有接收到请求时,会进行数据库连接检测,检查数据库是否还是连着的。检查数据库是否断开需要发送sql语句。报错是说这个sql语句没有设置。
解决方法:在yml中设置
1 2 3 druid: test-while -idle: true validation-query: SELECT 1
4.主启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 package com.wzg.springcloud;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication public class PaymentMain8081 { public static void main (String[] args) { SpringApplication.run(PaymentMain8081.class, args); } }
5.业务类
SQL :
1 2 3 4 5 CREATE TABLE `payment`( `id` bigint (20 ) NOT NULL AUTO_INCREMENT COMMENT 'ID' , `serial` varchar (200 ) DEFAULT '' , PRIMARY KEY (id) )ENGINE= InnoDB AUTO_INCREMENT= 1 DEFAULT CHARSET= utf8mb4
Entities :
实体类Payment:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 package com.wzg.springcloud.entities;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;import java.io.Serializable;@Data @AllArgsConstructor @NoArgsConstructor public class Payment implements Serializable { private Long id; private String serial; }
JSON封装体CommonResult:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 package com.wzg.springcloud.entities;import lombok.AllArgsConstructor;import lombok.Data;import lombok.NoArgsConstructor;@Data @AllArgsConstructor @NoArgsConstructor public class CommonResult <T> { private Integer code; private String message; private T data; public CommonResult (Integer code, String message) { this .code = code; this .message = message; this .data = null ; } }
DAO :
接口PaymentDao:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 package com.wzg.springcloud.dao;import com.wzg.springcloud.entities.Payment;import org.apache.ibatis.annotations.Mapper;import org.apache.ibatis.annotations.Param;@Mapper public interface PaymentDao { public int create (Payment payment) ; public Payment getPaymentById (@Param("id") Long id) ; }
MyBatis映射文件PaymentMapper.xml,路径:resources/mapper/PaymentMapper.xml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 <?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd" > <mapper namespace ="com.wzg.springcloud.dao.PaymentDao" > <insert id ="create" parameterType ="com.wzg.springcloud.entities.Payment" useGeneratedKeys ="true" keyProperty ="id" > insert into payment(serial) values (#{serial}); </insert > <resultMap id ="BaseResultMap" type ="com.wzg.springcloud.entities.Payment" > <id column ="id" property ="id" jdbcType ="BIGINT" /> <id column ="serial" property ="serial" jdbcType ="VARCHAR" /> </resultMap > <select id ="getPaymentById" parameterType ="java.lang.Long" resultMap ="BaseResultMap" > select * from payment where id = #{id}; </select > </mapper >
Service :
接口PaymentService
1 2 3 4 5 6 7 8 9 10 11 12 13 package com.wzg.springcloud.service;import com.wzg.springcloud.entities.Payment;import org.apache.ibatis.annotations.Param;public interface PaymentService { int create (Payment payment) ; Payment getPaymentById (@Param("id") Long id) ; }
实现类
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 package com.wzg.springcloud.service;import com.wzg.springcloud.dao.PaymentDao;import com.wzg.springcloud.entities.Payment;import org.springframework.stereotype.Service;import javax.annotation.Resource;@Service public class PaymentServiceImpl implements PaymentService { @Resource private PaymentDao paymentDao; @Override public int create (Payment payment) { return paymentDao.create(payment); } @Override public Payment getPaymentById (Long id) { return paymentDao.getPaymentById(id); } }
Controller :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 package com.wzg.springcloud.controller;import com.wzg.springcloud.entities.CommonResult;import com.wzg.springcloud.entities.Payment;import com.wzg.springcloud.service.PaymentService;import lombok.extern.slf4j.Slf4j;import org.springframework.web.bind.annotation.*;import javax.annotation.Resource;@RestController @Slf4j public class PaymentController { @Resource private PaymentService paymentService; @PostMapping(value = "/payment/create") public CommonResult create (@RequestBody Payment payment) { int result = paymentService.create(payment); log.info("插入结果:" + result); if (result > 0 ) { return new CommonResult <>(200 , "插入成功" , result); } else { return new CommonResult <>(444 , "插入失败" , null ); } } @GetMapping(value = "/payment/{id}") public CommonResult<Payment> getPaymentById (@PathVariable("id") Long id) { Payment payment = paymentService.getPaymentById(id); log.info("查询结果:" + payment); if (payment != null ) { return new CommonResult <>(200 , "查询成功" , payment); } else { return new CommonResult <>(444 , "查询失败,查询ID:" + id, null ); } } }
6.测试
浏览器 - http://localhost:8001/payment/1
7.小总结
Controller调用Service,Service调用Dao,Dao调用实体类,实体类关联sql
消费者订单模块 1.建Module
创建名为consumer-order80的maven工程。
2.改POM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 <?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 > cloud2022</artifactId > <groupId > com.wzg.springcloud</groupId > <version > 1.0-SNAPSHOT</version > </parent > <modelVersion > 4.0.0</modelVersion > <artifactId > consumer-order80</artifactId > <dependencies > <dependency > <artifactId > api-commons</artifactId > <groupId > com.wzg.springcloud</groupId > <version > 1.0-SNAPSHOT</version > </dependency > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-starter-web</artifactId > </dependency > <dependency > <groupId > org.springframework.boot</groupId > <artifactId > spring-boot-starter-actuator</artifactId > </dependency > <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 > org.springframework.boot</groupId > <artifactId > spring-boot-starter-test</artifactId > <scope > test</scope > </dependency > </dependencies > <properties > <maven.compiler.source > 8</maven.compiler.source > <maven.compiler.target > 8</maven.compiler.target > </properties > </project >
3.写YML
1 2 3 4 5 6 7 8 9 server: port: 80 # 在使用 SpringBoot 热部署插件 devtools ,同时启动多个Application 时,控制台会报这个警告; # 问题在于:DevToolsProperties 中配置了一个端口,默认是35729 spring: devtools: livereload: port: 3571
4.主启动
1 2 3 4 5 6 7 8 9 10 11 12 13 14 package com.wzg.springcloud;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;@SpringBootApplication public class OrderMain80 { public static void main (String[] args) { SpringApplication.run(OrderMain80.class,args); } }
5.业务类
实体类:还是entities
控制层:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 package com.wzg.springcloud.controller;import com.wzg.springcloud.entities.CommonResult;import com.wzg.springcloud.entities.Payment;import lombok.extern.slf4j.Slf4j;import org.springframework.web.bind.annotation.*;import org.springframework.web.client.RestTemplate;import javax.annotation.Resource;@RestController @Slf4j @RequestMapping("consumer") public class OrderController { public static final String PAYMENY_URL="http://localhost:8001" ; @Resource private RestTemplate restTemplate; @PostMapping("/payment/create") public CommonResult<Payment> create (Payment payment) { return restTemplate.postForObject(PAYMENY_URL+"/payment/create" , payment, CommonResult.class); } @GetMapping("/payment/{id}") public CommonResult<Payment> getPaymentById (@PathVariable("id") Long id) { return restTemplate.getForObject(PAYMENY_URL+"/payment/" +id,CommonResult.class); } }
配置类:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 package com.wzg.springcloud.config;import org.springframework.context.annotation.Bean;import org.springframework.context.annotation.Configuration;import org.springframework.web.client.RestTemplate;@Configuration public class ApplicationContextConfig { @Bean public RestTemplate getRestTemplate () { return new RestTemplate (); } }
6.测试
运行consumer-order80与provider-payment8001两工程
RestTemplate
RestTemplate提供了多种便捷访问远程Http服务的方法,是一种简单便捷的访问restful服务模板类,是Spring提供的用于访问Rest服务的客户端模板工具集
问题7:maven–install的时候提示maven-artifact2.9.0.pom有问题
解决方法:去maven仓库找到D:.m2\repository\org\apache\maven\maven-artifact\2.0.9直接删除该文件夹,重新下载
工程重构 提取消费者和提供者的重复代码,和之前学dubbo一个方法:抽取公共部分新建项目,通过maven–install到仓库其他项目要用的时候添加依赖
1.新建 api-commons
2.POM
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 <?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 > cloud2022</artifactId > <groupId > com.wzg.springcloud</groupId > <version > 1.0-SNAPSHOT</version > </parent > <modelVersion > 4.0.0</modelVersion > <artifactId > 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 > <properties > <maven.compiler.source > 8</maven.compiler.source > <maven.compiler.target > 8</maven.compiler.target > </properties > </project >
3.entities
将consumer-order80与provider-payment8001两工程的公有entities包移至api-commons工程下。
4.maven clean、install api-commons工程,以供给consumer-order80与provider-payment8001两工程调用。
5.订单80和支付8001分别改造
将consumer-order80与provider-payment8001两工程的公有entities包移除
引入api-commons依赖
1 2 3 4 5 <dependency > <groupId > com.lun.springcloud</groupId > <artifactId > cloud-api-commons</artifactId > <version > ${project.version}</version > </dependency >
6.测试
7.小总结
至此微服务入门结束