且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

java-web - SpringBoot如何使用JavaBean配置mybatis分页插件

更新时间:2023-09-29 14:23:58

PageHelper pageHelper这个没有实现Interceptor接口怎么给new Interceptor[]?
新版本中有个PageInterceptor类实现了Interceptor接口,这个时候赋值给new Interceptor[]才可行。

        // 设置MyBatis分页插件
        PageInterceptor pageInterceptor = new PageInterceptor();
        Properties properties = new Properties();
        properties.setProperty("helperDialect", "oracle");
        properties.setProperty("offsetAsPageNum", "true");
        properties.setProperty("rowBoundsWithCount", "true");
        pageInterceptor.setProperties(properties);
        bean.setPlugins(new Interceptor[]{pageInterceptor});