一、网关路由转发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并排除