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

springcloud 之gateway配置注意事项

springcloud 之gateway配置注意事项

1.springcloud 的底层用的是自家的WebFlux 以及netty 但是我们自己用的boot项目是tomcat 和 springmvc 这样会导致我们项目编译都不会通过
如果直接导入了web starter 会提示找到了mvc idea 不抽风的话会提示移除不恰当的springmvc
在这里插入图片描述
图1
这里提示我们的tomcat已经启动成功 但是报错:
java.lang.ClassCastException: org.springframework.core.io.buffer.DefaultDataBufferFactory cannot be cast to org.springframework.core.io.buffer.NettyDataBufferFactory
at org.springframework.cloud.gateway.filter.NettyWriteResponseFilter.lambda$filter 1 ( N e t t y W r i t e R e s p o n s e F i l t e r . j a v a : 82 ) [ s p r i n g c l o u d g a t e w a y c o r e 2.2.1. R E L E A S E . j a r : 2.2.1. R E L E A S E ] S u p p r e s s e d : r e a c t o r . c o r e . p u b l i s h e r . F l u x O n A s s e m b l y 1(NettyWriteResponseFilter.java:82) ~[spring-cloud-gateway-core-2.2.1.RELEASE.jar:2.2.1.RELEASE] Suppressed: reactor.core.publisher.FluxOnAssembly 1(NettyWriteResponseFilter.java:82)[springcloudgatewaycore2.2.1.RELEASE.jar:2.2.1.RELEASE]Suppressed:reactor.core.publisher.FluxOnAssemblyOnAssemblyException:
Error has been observed at the following site(s):
|_ checkpoint org.springframework.cloud.gateway.filter.WeightCalculatorWebFilter [DefaultWebFilterChain]
|_ checkpoint HTTP GET “/orderPay/order/1” [ExceptionHandlingWebHandler]

这时我已经排除了本modul的webstarter 但是还是提示要求我移除webstarter
好郁闷
好吧 我自己来exclusion 好吧/(ㄒoㄒ)/~~

org.springframework.cloud
spring-cloud-starter-netflix-eureka-client
2.2.3.RELEASE

org.springframework.boot
spring-boot-starter-web

org.springframework
spring-webmvc

        </exclusions>

    </dependency>

移除了webmvc 又报图1的错

接着移除我们的tomcat

    <!-- https://mvnrepository.com/artifact/org.springframework.cloud/spring-cloud-starter-netflix-eureka-server -->
    <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
        <version>2.2.3.RELEASE</version>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-web</artifactId>
        <exclusions>
            <exclusion>
                <groupId>org.springframework</groupId>
                <artifactId>spring-webmvc</artifactId>
            </exclusion>
            <exclusion>
                <artifactId>spring-boot-starter-tomcat</artifactId>
                <groupId>org.springframework.boot</groupId>
            </exclusion>
        </exclusions>

    </dependency>

yml配置如下

spring:
  main:
    allow-bean-definition-overriding: true
  application:
    name: gateway9527
  cloud:
    discovery:
      locator:
        enabled: true   #开启从注册中心动态创建路由的功能,利用微服务名进行路由
    gateway:
      routes:
        - id: before_route
          uri: lb://PRODUCT
          predicates:
            - Path=/orderPay/order/**
            - 

当当当 !!
在这里插入图片描述
看到提示netty启动成功我们的gateway整合cloud完美成功啦 接下来就是一些配置啦

总结:

cloud整合gateway的时候一定要exclusion webstarter 如果移除了还是不行 那我们就自己手动exclusion tomcat 和mvc
切记!切记!切记!

相关文章:

  • JS BOM
  • 领英工具-领英精灵群发消息功能解析
  • [答疑]微信餐馆案例中,“启动二维码对应的程序”这个用例合理吗
  • Defocus(散焦)
  • jvm中对象内存空间的分配与回收
  • Shiro 550、721
  • Mybatis开启日志
  • linux中查看MySQL数据库表数据及结构并导入sql脚本
  • Maven dependency 详解
  • Hadoop搭建HA遇到的坑
  • Docker目录映射
  • INnoDB(索引与算法)
  • docker常见面试题
  • 第09章 MyBatisPlus实现查询功能
  • 第06章 MyBatisPlus概述
  • Babel配置的不完全指南
  • css选择器
  • Java 多线程编程之:notify 和 wait 用法
  • node.js
  • Python 基础起步 (十) 什么叫函数?
  • Python学习之路16-使用API
  • Vim 折腾记
  • 基于Mobx的多页面小程序的全局共享状态管理实践
  • 基于阿里云移动推送的移动应用推送模式最佳实践
  • 强力优化Rancher k8s中国区的使用体验
  • 区块链将重新定义世界
  • 文本多行溢出显示...之最后一行不到行尾的解决
  • 通过调用文摘列表API获取文摘
  • 整理一些计算机基础知识!
  • ###项目技术发展史
  • #常见电池型号介绍 常见电池尺寸是多少【详解】
  • (10)工业界推荐系统-小红书推荐场景及内部实践【排序模型的特征】
  • (C语言)共用体union的用法举例
  • (MIT博士)林达华老师-概率模型与计算机视觉”
  • (vue)页面文件上传获取:action地址
  • (二)pulsar安装在独立的docker中,python测试
  • (附源码)计算机毕业设计ssm本地美食推荐平台
  • (四)库存超卖案例实战——优化redis分布式锁
  • .naturalWidth 和naturalHeight属性,
  • .net 4.0 A potentially dangerous Request.Form value was detected from the client 的解决方案
  • .NET Framework杂记
  • .NET 设计一套高性能的弱事件机制
  • .NET/C# 使用 #if 和 Conditional 特性来按条件编译代码的不同原理和适用场景
  • .NET/C# 异常处理:写一个空的 try 块代码,而把重要代码写到 finally 中(Constrained Execution Regions)
  • .net连接oracle数据库
  • .NET下的多线程编程—1-线程机制概述
  • @DateTimeFormat 和 @JsonFormat 注解详解
  • @RequestMapping-占位符映射
  • [Android 数据通信] android cmwap接入点
  • [bzoj 3124][sdoi 2013 省选] 直径
  • [bzoj1912]异象石(set)
  • [I2C]I2C通信协议详解(一) --- 什么是I2C
  • [linux]--关于进程概念(上)
  • [POJ 1915] Knight Moves
  • [Pytorch]:PyTorch中张量乘法大全