聚合服务,或者叫做数据聚合服务,顾名思义就是把所需要的服务给聚集在一起,这个概念在现实中非常重要,因为聚合服务做得好,能尽可能的减少服务治理的问题。
本篇中,我们将会采用resttemplate+ribbon来进行构建聚合服务。
首先是在pom文件中引入我们需要的文件,以下两个文件默认zuul已经存在,但是我们重新引入,容易看一些。
pom文件新增
<!-- 负载均衡器 -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-ribbon</artifactId>
</dependency>
<!-- springboot核心web -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
接下来,我们新建一个resttemplate的配置类
RestTemplateConfig配置类
/**
* All rights Reserved, Designed By OprCalf
* Copyright: Copyright(C) 2016-2020
* Company LengYin Ltd.
*/
packa