Giter Site home page Giter Site logo

Comments (9)

BearBig-CN avatar BearBig-CN commented on August 22, 2024 1

问题解决了,是因为系统启动的时候PageHelperAutoConfiguration会自动注册,只需要在启动的时候排除掉即可,写法:@SpringBootApplication(exclude = PageHelperAutoConfiguration.class)。

from mybatis-pagehelper.

abel533 avatar abel533 commented on August 22, 2024

有几个 sqlSession ?

from mybatis-pagehelper.

jandyu avatar jandyu commented on August 22, 2024

用了两个@configuration注册了两个DataSource,对应有两个SqlSessionFactory,分别扫描自己的mapper,一个为主数据加了@primary,另一个没有加。只有调用@primary的mapper前的pagehelper有效,可以分页,无@primary的pagehelper设置无效。

from mybatis-pagehelper.

abel533 avatar abel533 commented on August 22, 2024

分页插件配置两个了吗?

from mybatis-pagehelper.

jandyu avatar jandyu commented on August 22, 2024

原来一个数据源的代码是用PageHelper.startPage(query.getPage(), query.getPageSize())进行分页的,
数据源和mapper调整为两套后,出现这个问题。
spring-boot,在application.yml中有如下配置
pagehelper:
helperDialect: SqlServer2014Dialect
reasonable: true
supportMethodsArguments: true
params: count=countSql

是否支持两个分页插件,如果可以两个分页插件如何配置?沿用原来的startPage这种调用模式是否可以?

from mybatis-pagehelper.

abel533 avatar abel533 commented on August 22, 2024

一个sqlsession就得对应一个配置。。静态方法可以用,不会乱。

from mybatis-pagehelper.

jandyu avatar jandyu commented on August 22, 2024

终于搞定,不过发现主数据源@primary中不能用setPlugins来设置PageInterceptor,会生成错误的sql,导致错误,只能在application.yml中配置,才能有效。
而另一个数据源必须在SqlSessionFactory中setPlugins才能有效,在application.yml无法配置。
有点弄不明白,应该都可以用setPlugins配置,为什么@primary就不可以?

from mybatis-pagehelper.

AlexanLee avatar AlexanLee commented on August 22, 2024

我也发现,好像配置多数据源之后,分页有问题。

from mybatis-pagehelper.

BearBig-CN avatar BearBig-CN commented on August 22, 2024

@jandyu 你是怎么解决的?我也是在SqlSessionFactory设置了Plugins,但是在执行SQL时提示配置了多个分页插件的异常

from mybatis-pagehelper.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.