当前位置: 首页 > news >正文

在线写作网站百度知道客服电话人工服务

在线写作网站,百度知道客服电话人工服务,怎做网站,做网站设计制作的公司一、前言 本篇主要是围绕着两个点,1、集成 Feign,2、分离feign接口层,独立服务; 还有一点就是上篇文章的服务 iot-channel、system-server 服务名称调整成为了 chain-iot-channel、chain-system二、搭建 chain-common 服务 pom.…

一、前言

本篇主要是围绕着两个点,1、集成 Feign,2、分离feign接口层,独立服务;
还有一点就是上篇文章的服务 iot-channel、system-server 服务名称调整成为了 chain-iot-channel、chain-system

二、搭建 chain-common 服务

pom.xml 
    <properties><!-- lombok --><lombok.version>1.18.26</lombok.version></properties><!-- Dependencies --><dependencies><!-- Lombok Dependency --><dependency><groupId>org.projectlombok</groupId><artifactId>lombok</artifactId><version>${lombok.version}</version></dependency></dependencies>
chain-common 项目暂时只是空项目

二、搭建 chain-starter/chain-feign-starter 服务

chain-starter
chain-starter 服务只是一个 pom 项目,主要作用是来包含一些启动服务,例如 chain-feign-starter 之类
chain-feign-starter
搭建这个服务的主要是目的是,后续会有很多服务会引用到 Feign 框架,如果在每个服务独立引用 Feign,在后续的升级版本或需要增加 Feign 的配置就会很麻烦,所以现在统一管理起来
    <dependencies><!-- feign 客户端 --><dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId></dependency></dependencies>

三、chain-system、chain-iot-channel 集成 Feign

pom.xml 增加 Feign 引用
        <dependency><groupId>com.chain</groupId><artifactId>chain-feign-starter</artifactId><version>${chain.version}</version></dependency>

四、服务配置 Feign

1、启动服务增加注解
在 chain-system、chain-iot-channel 启动服务都增加 @EnableFeignClients 注解,开发Feign 客户端
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class IotChannelServeApp {public static void main(String[] args) {SpringApplication.run(IotChannelServeApp.class, args);}
}
@SpringBootApplication
@EnableDiscoveryClient
@EnableFeignClients
public class SystemServerApp {public static void main(String[] args) {SpringApplication.run(SystemServerApp.class);}
}
2、chain-iot-channel 服务增加被调用接口
IotChannelInterface.java
@RestController
@RequestMapping(path = "/iot/channel/open/api")
public class IotChannelInterface {@Override@GetMapping(path = "/testIotChannelFeign")public String testIotChannelFeign() {return "test iot channel feign open api";}
}
3、chain-system 服务增加调用接口
SystemForIotChannelInterfaceClient.java
@FeignClient(name = "chain-iot-channel", url = "http://localhost:10020", path = "/iot/channel/open/api")
public interface SystemForIotChannelInterfaceClient  {@GetMapping(path = "/testIotChannelFeign")String testIotChannelFeign();
}
在这里需要注意一点的是,如果在 IotChannelInterface.java 中配置了@RequestMapping(path = "/iot/channel/open/api"),那么在 SystemForIotChannelInterfaceClient.java 中就需要增加 path = "/iot/channel/open/api" 配置
还有另一点就是如果单独使用 Feign,没有集成 Ribbon,那么就需要在 @FeignClient 注解中增加 url 配置项,因为没有 Ribbon 框架是无法实现负载均衡,那么 name 参数的配置,不会直接调用到服务的,只能增加 url 配置

五、独立 Feign 调用接口

1、增加 chain-open-api/chain-iot-channel-api 服务
chain-open-api
chain-open-api 和 chain-starter 服务一样,只是一个 pom 项目,主要作用是来包含项目中每个服务对应的 open api 项目
chain-iot-channel-api
pom.xml
    <dependencies><!-- 自定义 Feign --><dependency><groupId>com.chain</groupId><artifactId>chain-feign-starter</artifactId><version>${chain.version}</version></dependency></dependencies>
IotChannelInterfaceApi.java
public interface IotChannelInterfaceApi {/*** 测试 iot channel 服务是否可用** @return String*/@GetMapping(path = "/testIotChannelFeign")String testIotChannelFeign();
}
2、增加对 chain-iot-channel-api 的引用
chain-iot-channel\chain-system
pom.xml
        <dependency><groupId>com.chain</groupId><artifactId>chain-iot-channel-api</artifactId><version>${chain.version}</version></dependency>
3、改造IotChannelInterface.java、SystemForIotChannelInterfaceClient.java
IotChannelInterface.java、
@RestController
@RequestMapping(path = "/iot/channel/open/api")
public class IotChannelInterface implements IotChannelInterfaceApi {@Overridepublic String testIotChannelFeign() {return "test iot channel feign open api";}
}
SystemForIotChannelInterfaceClient.java
@FeignClient(name = "chain-iot-channel", url = "http://localhost:10020", path = "/iot/channel/open/api")
public interface SystemForIotChannelInterfaceClient extends IotChannelInterfaceApi {
}

最后附上项目结构图
在这里插入图片描述

http://www.ds6.com.cn/news/98839.html

相关文章:

  • 网页版梦幻西游五行斗法关闭站长工具seo综合查询
  • 如何学剪辑视频教程浙江seo
  • 外贸仿牌网站建设清远今日头条最新消息
  • b2c电子商务网站系统下载深圳seo优化推广
  • 网页制作与网站建设策划书案例百度 站长工具
  • 代挂网站维护seo外包优化网站
  • 网站怎么做跳转页面销售培训课程
  • 制作做网站的基本流程seo云优化
  • 厦门八优网站建设网络营销的策划方案
  • 河南做网站联系电话今天最新新闻事件报道
  • 网站建设 唐山廊坊seo排名霸屏
  • 如何生成自己的网站seo网站优化怎么做
  • 如何做登录网站申请自媒体平台注册
  • 电商运营网站 建设企业百度推广怎么收费
  • 做足球预测的网站seo网站关键词排名优化公司
  • 上海微信网站公司哪家好编程培训班学费一般多少钱
  • 南宁网站建设团队推广公司是做什么的
  • 谷歌网站的主要内容关键词查网址
  • 腾讯云网站备案如何快速提升自己
  • 平湖网站建设公司克电商运营助理
  • 网站开发+.net+开源桂林seo
  • 中牟高端网站建设网络营销案例及分析
  • 凡客诚品正品男宁波seo哪家好
  • 广州做公司网站的公司有哪些seo是指什么
  • 外贸公司网站建设费的会计科目合肥网站优化推广方案
  • 买网站空间需要知道的省委副书记
  • 广东哪家网站建设太原免费网站建站模板
  • 绵阳市做公司网站百度收录查询api
  • 莆田做外贸网站鄂州网站seo
  • 镇江网站设计建设百度排名优化软件