spring boot 2.0 提示 No primary or default constructor found for interface Pageable 解决办法

在SpringBoot 2.0  配置拦截器   建议继承此配置类

 * @date 2018/06/03
 */
@Configuration
public class WebMvcConfig extends WebMvcConfigurationSupport {

然后你会发现Controller中无法注入Pageable了,错误提示如下

No primary or default constructor found for interface org.springframework.data.domain.Pageable

解决方法

出现该问题的真正原因如下: 1. 如果要配置WebMvcConfigurationSupport那么就不要添加@EnableSpringDataWebSupport 2. 如果要使用@EnableSpringDataWebSupport那么配置文件就不应该继承WebMvcConfigurationSupport,可以通过实现WebMvcConfigurer接口来达到同样目的 这个问题只需要取消继承WebMvcConfigurationSupport,添加@EnableSpringDataWebSupport 注解就可以了

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
根据引用\[1\]中的内容,Gateway的webflux和SpringBoot的web存在冲突,因此无法使用传统的HttpServletRequest方式来获取请求数据。在Gateway网关的controller接口中,无法直接获取ServerHttpRequest,需要通过获取ServerWebExchange对象,然后从中获取ServerHttpRequest。在代码中,可以使用exchange.getRequest()来获取ServerHttpRequest对象。然后可以通过ServerHttpRequest对象获取请求的URI、接口标识、IP地址、日期和请求头等信息。 根据引用\[2\]中的内容,当在微服务网关Gateway中使用传统的HttpServlet方式去获取请求中的数据时,可能会出现报错"No primary or default constructor found for interface org.springframework.web.multipart.MultipartFile"。这个错误通常是因为在Controller的方法参数上加上了HttpServerRequest,而HttpServerRequest没有默认的构造函数。解决这个问题的方法是使用MultipartFile来代替HttpServerRequest来处理文件上传的请求。 综上所述,如果在Gateway中遇到报错"No primary or default constructor found for interface org.springframework.web.multipart.MultipartFile",可以尝试使用MultipartFile来处理文件上传的请求。 #### 引用[.reference_title] - *1* *2* [No primary or default constructor found for interface javax.servlet.http.HttpServletRequest](https://blog.csdn.net/CSDN2497242041/article/details/130117238)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v91^control_2,239^v3^insert_chatgpt"}} ] [.reference_item] [ .reference_list ]

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值