网关:springcloud gateway搭建踩坑记录

一、网关路由转发404(由于gateway和springboot-web冲突导致)

1、路由配置如下,前端请求192.168.0.152:8104/gateway/thirds/user/loginOut后会转发到8103的服务

server:
  port: 8104
spring:
  cloud:
    gateway:
      discovery:
        locator:
          #是否与服务发现组件结合,通过serviceId转发到具体的实例。默认为false,设为true开始根据serviceId创建路由功能
          enabled: true
          #是将请求路径上的服务名配置为小写(因为服务注册的时候,向注册中心注册时将服务名转成大写的了)
          lower-case-service-id: true
      routes:
        - id: ac-gateway
          uri: http://192.168.0.152:8103/thirds
          predicates:
            - Path=/user/**
        #          filters:
        #            - StripPrefix=1
        - id: ac-gatewaytwo
          uri: http://192.168.0.152:8103
          predicates:
            - Path=/gateway/thirds/user/**
          filters:
            - StripPrefix=1

2、依赖冲突,由spring-cloud-config-server引起

1)、排除依赖
<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-config-server</artifactId>
            <exclusions>
                <exclusion>
                    <groupId>org.springframework.boot</groupId>
                    <artifactId>spring-boot-starter-web</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
2)、如有问题,可能需要手动添加mvc的jar包
 <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-webmvc</artifactId>
        </dependency>

3、依赖寻找方法:

1)、打开pom文件,空白处右键点击>>maven>> show dependencies如下,找到包含冲突的jar并排除

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值