java - 发送请求'POST' Zuul 和响应:不支持请求方法'GET' | 弹簧靴
问题描述
我正在使用 Spring Cloud,我配置了 Eureka、Zuul。在 Spring Boot 中部署 Api Rest 并通过 Zuul 使用 rest POST 服务时,我收到 HTTP 405 错误消息。
我正在检查日志并出现以下消息:
Request method 'GET' not supported
2019-12-11 12: 19: 04.679 WARN 5724 --- [nio-8089-exec-6] .m.m.a.ExceptionHandlerExceptionResolver: Resolved [org.springframework.web.HttpRequestMethodNotSupportedException: Request method 'GET' not supported]
奇怪的是,当我直接使用该服务时,它可以正常工作,但是由于 Zuul 似乎我是通过 GET 发送它,但实际上我总是通过 POST 发送它。
Api Rest 使用 JWT 配置了安全性,我不知道我是否需要做任何额外的配置
非常感谢,如果有人可以帮助我,我将不胜感激。
应用程序.yml
spring:
application:
name: kentaurus-zuul-server
server:
port: 8082
servlet:
contextPath: /api/v1
#Endpoints
#endpoints:
# restart:
# enabled: true
#shutdown:
# enabled: true
#health:
# sensitive: false
#Zuul routes active
zuul:
routes:
kentaurus-page-core:
service-id: kentaurus-page-core
path: /public/kentaurus-page/**
sensitiveHeaders: Cookie,Set-Cookie
url: http://localhost:8089
# stripPrefix : true
management:
endpoints:
kentaurus-page-core:
exposure:
include: "*"
exclude:
#Eureka Instance ID
eureka:
client:
registerWithEureka: true
fetchRegistry: true
serviceUrl:
defaultZone: http://localhost:8081/eureka/
instance:
hostname: localhost
instanceId: ${spring.application.name}:${server.port}
#Ribbon Activation
ribbon:
eureka:
enabled: true
pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.1.3.RELEASE</version>
<relativePath /> <!-- lookup parent from repository -->
</parent>
<groupId>com.kentaurus.zuul.server</groupId>
<artifactId>kentaurus-zuul-server</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>kentaurus-zuul-server</name>
<description>Eureka Service</description>
<properties>
<java.version>1.8</java.version>
<spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<!-- Dependency to use a spring cloud config server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!-- Dependency to register the service within Eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-zuul</artifactId>
</dependency>
<!-- Dependency to use a spring cloud config server -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-config</artifactId>
</dependency>
<!-- Dependency to register the service within Eureka -->
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-starter-netflix-eureka-client</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
</dependencies>
<!-- Dependency Management -->
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.springframework.cloud</groupId>
<artifactId>spring-cloud-dependencies</artifactId>
<version>${spring-cloud.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
</dependencies>
</dependencyManagement>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
</plugins>
</build>
</project>
解决方案
推荐阅读
- google-sheets - 搜索多列的 Google 表格查询
- sqlite - SQLITE_ERROR:靠近“?” 在 ExpressJS 中添加列时
- android - 带有 ConstraintLayout 的两列
- google-apps-script - 遍历谷歌表格中的单元格并创建具有特定格式的字符串
- sql-server - 无法使用 PySpark 插入 SQL,但可以在 SQL 中使用
- linkedin - 是否可以使用 Linked API v2 获取职位列表?
- css - scss 使用 laravel-mix 编译成功,但在浏览器中没有变化
- c# - Vector3.Lerp() 末尾的“分数”值是多少?统一声明
- docker - Docker推送“拒绝:请求的资源访问被拒绝”
- javascript - 如何使用 Javascript 将查询参数附加到我的 URL?