项目场景:
问题描述:
POST 请求时,抛出异常:
No primary or default constructor found for interface org.springframework.http.server.reactive.ServerHttpRequest
- 1
原因分析:
应用系统定制开发以下内容摘自:stackoverflow
链接: .
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