应用系统定制开发No primary or default constructor found for interface ServerHttpRequest问题

项目场景:


问题描述:

POST 请求时,抛出异常:

No primary or default constructor found for interface org.springframework.http.server.reactive.ServerHttpRequest
  • 1

原因分析:

应用系统定制开发以下内容摘自:stackoverflow
链接: .

The Spring Boot reference documentation says that deploying Spring WebFlux application as WARs is not a supported use case.

Spring Boot 参考文档说,将 Spring WebFlux 应用程序部署为 war 不是一个受支持的用例。

Also, the stacktrace in your question shows that you’re actually running a Spring MVC application, and Spring MVC doesn’t support org.springframework.http.server.reactive.ServerHttpRequest as a handler argument. Something in your build must be bringing Spring MVC.

此外,你问题中的 stacktrace 显示你实际上运行的是一个 Spring MVC 应用程序,而 Spring MVC 不支持 org..http.server.reactive。作为处理程序参数。你的构建中一定有什么东西带来了 springmvc。

When both WebFlux and MVC are present, Spring Boot will configure automatically your app as a Spring MVC app.

当 WebFlux 和 MVC 都存在时,Spring Boot 会自动将你的应用配置为 Spring MVC 应用。


解决方案:

1、用WebFlux时,获取请求头的信息时使用:ServerHttpRequest

2、用MVC时(或WebFlux、MVC依赖同时存在时),获取http请求头的信息使用:HttpServletRequest

网站建设定制开发 软件系统开发定制 定制软件开发 软件开发定制 定制app开发 app开发定制 app开发定制公司 电商商城定制开发 定制小程序开发 定制开发小程序 客户管理系统开发定制 定制网站 定制开发 crm开发定制 开发公司 小程序开发定制 定制软件 收款定制开发 企业网站定制开发 定制化开发 android系统定制开发 定制小程序开发费用 定制设计 专注app软件定制开发 软件开发定制定制 知名网站建设定制 软件定制开发供应商 应用系统定制开发 软件系统定制开发 企业管理系统定制开发 系统定制开发