Spring Cloud API网关部署在tomcat上后不工作

发布于 2025-01-13 08:55:50 字数 977 浏览 2 评论 0原文

在tomcat上部署网关war文件后无法访问它。

application.yml 文件设置

server:
  port: 9000
  servlet:
    context-path: /gateway

spring:
  cloud:
    gateway:
      routes:
      - id: mysqlservice
        uri:  http://localhost:8080
        predicates:
        - Path= /gateway/mysql/**
        filters:
        - StripPrefix=1     
        
        
      - id: xyzservice
        uri:  http://localhost:8080
        predicates:
         - Path= /gateway/xyz/**    
        filters:
        - StripPrefix=1     
             
        
      - id: lightservice
        uri:  http://localhost:8080
        predicates:
         - Path= /gateway/light/**    
        filters:
        - StripPrefix=1     
        
    

当我通过正常的 Spring Boot JAR 文件运行它时,上述配置工作正常

。 http://localhost:9000/gateway/mysql/mysqlapi/test

当它部署在 tomcat 服务器上时我无法访问

它前任。 http://localhost:8080/gateway/mysql/mysqlapi/test

那么我如何从tomcat服务器访问它呢?

After deploying the gateway war file on tomcat not able to access it.

application.yml file setup

server:
  port: 9000
  servlet:
    context-path: /gateway

spring:
  cloud:
    gateway:
      routes:
      - id: mysqlservice
        uri:  http://localhost:8080
        predicates:
        - Path= /gateway/mysql/**
        filters:
        - StripPrefix=1     
        
        
      - id: xyzservice
        uri:  http://localhost:8080
        predicates:
         - Path= /gateway/xyz/**    
        filters:
        - StripPrefix=1     
             
        
      - id: lightservice
        uri:  http://localhost:8080
        predicates:
         - Path= /gateway/light/**    
        filters:
        - StripPrefix=1     
        
    

The above configuration works fine when I run it through the normal spring boot JAR file

Ex. http://localhost:9000/gateway/mysql/mysqlapi/test

when it deployed on the tomcat server that time I am not able to access it

Ex. Ex. http://localhost:8080/gateway/mysql/mysqlapi/test

So how can i access it from tomcat server?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

潇烟暮雨 2025-01-20 08:55:50

您不能,因为不支持

Spring Cloud Gateway 需要 Spring Boot 和 Spring Webflux 提供的 Netty 运行时。它不适用于传统的 Servlet 容器或构建为 WAR 时。

You can’t as it is not supported:

Spring Cloud Gateway requires the Netty runtime provided by Spring Boot and Spring Webflux. It does not work in a traditional Servlet Container or when built as a WAR.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文