Webflux使用分页查询报错

2021-03-17  本文已影响0人  Anson_1f2a

项目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())
    }
}
上一篇下一篇

猜你喜欢

热点阅读