美文网首页
Webflux使用分页查询报错

Webflux使用分页查询报错

作者: Anson_1f2a | 来源:发表于2021-03-17 11:18 被阅读0次

项目spring-web改为使用spring-webflux时,分页查询时报异常No primary or single public constructor found for interface org.springframework.data.domain.Pageable - and no default constructor found either

image.png
解决方案:
自己写一个config类
import org.springframework.context.annotation.Configuration
import org.springframework.data.web.ReactivePageableHandlerMethodArgumentResolver
import org.springframework.web.reactive.config.WebFluxConfigurer
import org.springframework.web.reactive.result.method.annotation.ArgumentResolverConfigurer

/**
 * @Author  Anson
 * @Date  2021/3/12 12:12
 * @Version 1.0
 */
@Configuration
class WebConfig : WebFluxConfigurer {

    override fun configureArgumentResolvers(configurer: ArgumentResolverConfigurer) {
        configurer.addCustomResolver(ReactivePageableHandlerMethodArgumentResolver())
    }
}

相关文章

网友评论

      本文标题:Webflux使用分页查询报错

      本文链接:https://www.haomeiwen.com/subject/nbbscltx.html