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

网站名称是什么意思如何做好网上销售

网站名称是什么意思,如何做好网上销售,澳门118开118186com,网站建设后台编程目录地址: SpringCloudAlibaba整合-CSDN博客 这里只关注代码部分,至于sentinel服务UI的实用,后面可以补上 这里做一个改造: 因为sentinel可以和openfeign结合使用,为微服务做熔断降级; 为了方便微服务之间…

目录地址:

SpringCloudAlibaba整合-CSDN博客

这里只关注代码部分,至于sentinel服务UI的实用,后面可以补上

这里做一个改造:

因为sentinel可以和openfeign结合使用,为微服务做熔断降级;

为了方便微服务之间的调用,把远程调用接口移动到api模块;

所以把order中的openfeign和loadbalancer依赖,放到api的pom中,并且把order中Remote接口,移动到api中;后续order只需要引入api的依赖,调用api中的接口即可

1.在api中引入sentinel和openfeign

<!--openfeign-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-openfeign</artifactId>
</dependency><!--loadbalancer-->
<dependency><groupId>org.springframework.cloud</groupId><artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency><!--sentinel-->
<dependency><groupId>com.alibaba.cloud</groupId><artifactId>spring-cloud-starter-alibaba-sentinel</artifactId>
</dependency>

2.把接口从order转移到api,并修改

@FeignClient(name="my-user", fallbackFactory = UserServiceFactory.class)
public interface RemoteUserService {@RequestMapping("/user/listAll")public List<User> listAll();@GetMapping("/user/getById")public User getById(@RequestParam("id") Integer id);
}

api模块,添加UserServiceFactory类

@Component
public class UserServiceFactory implements FallbackFactory<RemoteUserService> {@Overridepublic RemoteUserService create(Throwable cause) {return new RemoteUserService() {@Overridepublic List<User> listAll() {return null;}@Overridepublic User getById(Integer id) {System.out.println("user服务异常");return null;}};}
}

3.注意要把UserServiceFactory放到META-INF/spring.factories文件中

org.springframework.boot.autoconfigure.EnableAutoConfiguration=\
com.test.api.remote.fallbackFactory.UserServiceFactory,\
com.test.api.remote.fallbackFactory.ProductServiceFactory

4.order引入api依赖,并在启动类添加注解,扫描feignClient接口

@EnableFeignClients(basePackages = {"com.test.api.remote"})

5.order的配置文件添加

feign:sentinel:enabled: true

6.重启服务,访问接口,正常访问

此时停止user服务,再次访问order接口,返回null,后台日志打印“user服务异常”

http://www.hkea.cn/news/111651/

相关文章:

  • 阿里云部署一个自己做的网站吗电商网站搭建
  • 免费汽车租赁网站模板网站域名解析ip查询
  • 企业解决方案官网国内seo排名分析主要针对百度
  • 变态版手游石景山区百科seo
  • 阿里云控制台登录入口seo矩阵培训
  • wordpress苗木模板网站搜索排优化怎么做
  • 网站图片引导页怎么做重庆seo招聘
  • 如何做属于自己的领券网站郑州百度网站优化排名
  • 建设银行益阳市分行桃江支行网站公司页面设计
  • vps 网站上传网站seo优化是什么意思
  • wordpress cos腾讯云seo网站优化收藏
  • 鹤岗商城网站建设免费域名申请
  • 江苏三个地方疫情严重抖音视频排名优化
  • 竞价排名广告东莞关键词排名快速优化
  • 做视频网站要什么格式好网络营销公司怎么注册
  • 企业专业网站建设快速网站搭建
  • 武威建设网站的网站google谷歌搜索
  • 长沙公司做网站多少钱推广平台怎么做
  • 现在大家做电商网站用什么源码营销策略都有哪些
  • 可以做试卷的网站英语怎么说seo关键词排名优化系统源码
  • 网站怎么设置支付功能企业网站的主要类型有
  • 成都圣都装饰装修公司北京搜索优化排名公司
  • 境外建设网站贴吧互联网域名注册查询
  • 广州建站工作室淘客推广怎么做
  • 中国最大的网站建设公司百度广告联盟点击一次多少钱
  • wordpress单页主题营销seo手机关键词网址
  • dedecms做电影网站韩国最新新闻
  • 哪个网站做废旧好如何在百度上发布自己的广告
  • 网站表单及商品列表详情模板如何搭建自己的网站
  • 网站域名登记证明百度高级搜索怎么用