当前位置: 代码迷 >> 综合 >> spring boot 2.0 提示 No primary or default constructor found for interface Pageable 解决办法
  详细解决方案

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

热度:58   发布时间:2023-12-28 19:37:03.0

在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 注解就可以了

  相关解决方案