Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/spring-boot/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用配置为基于UI路由的网关的简单spring引导404_Spring_Spring Boot_Spring Boot Actuator - Fatal编程技术网

使用配置为基于UI路由的网关的简单spring引导404

使用配置为基于UI路由的网关的简单spring引导404,spring,spring-boot,spring-boot-actuator,Spring,Spring Boot,Spring Boot Actuator,我使用网关框架创建了一个简单的spring启动应用程序 路由的配置如下所示: spring: cloud: gateway: routes: - id: rewritepath_route uri: http://example.org predicates: - Path=/foo/** filters: - RewritePath=/foo(?<segment>/?

我使用网关框架创建了一个简单的spring启动应用程序

路由的配置如下所示:

spring:
  cloud:
    gateway:
      routes:
      - id: rewritepath_route
        uri: http://example.org
        predicates:
        - Path=/foo/**
        filters:
        - RewritePath=/foo(?<segment>/?.*), $\{segment}

      - id: gateway_test_route
        uri: http://example.org
        predicates:
        - Path=/test
spring:
云:
网关:
路线:
-id:重写路径\路由
uri:http://example.org
谓词:
-路径=/foo/**
过滤器:
-重写路径=/foo(?/?*),$\{segment}
-id:网关\测试\路由
uri:http://example.org
谓词:
-路径=/test
但是,前往以下任一路线仅显示404:

转到此端点

显示HTTP错误代码500内部服务器错误

转到执行器点:

这个很好用

不确定这是否是一个问题,但路由是从网关文档获得的


我已将代码上载到

我不熟悉S-C-G,但当您通过localhost调用应用程序时,“uri”将是“localhost”,而不是“example.org”

在本地测试此路由时,需要使用Postman或curl等工具传递合适的HTTP“主机”头。也许还有浏览器插件

因此,在向本地运行的应用程序发出请求时,请尝试传递“Host:example.org”