Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
302 views
in Technique[技术] by (71.8m points)

spring-cloud 使用gateway配置路由的问题??

注册中心使用Eureka
这里有一台登录微服务
登录接口地址:http://127.0.0.1:7500/auth/login
同时也注册到了Eureka了。

然后gateway网关也注册到了注册中心,然后配置yml

server:
  port: 8500

eureka: 
  client:
    service-url:
      defaultZone: http://127.0.0.1:7001/eureka/
    register-with-eureka: true
    fetch-registry: true
  instance:
    instance-id: gateway-server8500  #修改eureka默认描述信息就是status


info: 
  app.name: gateway-server
  company.name: com.cpmscloud


spring:
  application:
    name: gateway-server
  cloud:
    #设置路由规则
    gateway:
      enabled: true  #开启网关
      discovery: 
        locator:
          lowerCaseServiceId: true #服务id设置为小写
          enabled: true 

      routes:
      - id: oauth-server-tests   
        uri: lb://oauth-server       
        predicates:                     
        - Path=/gateService/**   
        filters:
        - StripPrefix=1

通过网关服务访问
http://127.0.0.1:8500/gateService/auth/login

提示404:

{

 "timestamp": "2020-07-19T06:53:59.429+0000",

 "status": 404,

 "error": "Not?Found",

 "message": "No?message?available",

 "path": "/gateService/auth/login"

}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
等待大神解答

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to MLink Developer Q&A Community for programmer and developer-Open, Learning and Share
...