Comments (5)
经过断点调试发现,需要以下配置:
<bean class="com.github.pagehelper.PageInterceptor">
<property name="properties">
<value>dialect=</value>
</property>
</bean>
根据我的观察,PageIntercepor.setProperties
方法里是设置dialect
属性值的,如果在配置文件中没有调用到setProperties
方法,则dialect
为空,也没有默认值,所以导致执行插件的intercept
方法时,调用dialect.afterAll()
方法发生NPE。
from mybatis-pagehelper.
生成XMLConfigBuilder的前提是有mybatis的配置文件,可我是用spring的属性配置方式。这样在SqlSessionFactoryBean.buildSqlSessionFactory
的方法里由于configLocation
属性值为空,不会生成xmlConfigBuilder
对象,所以都不会执行到pluginElement
方法。
from mybatis-pagehelper.
正常配置的情况下,只有用 pagehelper-starter 1.0.0 版本才会出现。
单独的分页插件,只有配置多次才会出现。
from mybatis-pagehelper.
在 XMLConfigBuilder
中:
private void pluginElement(XNode parent) throws Exception {
if (parent != null) {
for (XNode child : parent.getChildren()) {
String interceptor = child.getStringAttribute("interceptor");
Properties properties = child.getChildrenAsProperties();
Interceptor interceptorInstance = (Interceptor) resolveClass(interceptor).newInstance();
interceptorInstance.setProperties(properties);
configuration.addInterceptor(interceptorInstance);
}
}
}
源码中,不管 properties 是否有值,都会执行 setProperties 方法,不是你说的问题。你可以看看这里。
from mybatis-pagehelper.
非常感谢!!
确实有这个问题。
后面我会考虑在 public Object plugin(Object target)
方法中初始化插件。
from mybatis-pagehelper.
Related Issues (20)
- mybatis自定义拦截器修改sql后执行空指针 HOT 1
- 这个参数根本没用pagehelper.auto-dialect=false,代码里一直都是true,无法控制 HOT 4
- 多数据库方言就有问题,假如我第一次使用了mysql,然后使用sqlserver查询就还是用的limit分页;代码逻辑有问题具体看详情 HOT 9
- Springboot3版本supportMethodsArguments参数失效 HOT 2
- NoClassDefFoundError: net/sf/jsqlparser/statement/select/ParenthesedSelect HOT 1
- 开启asyncCount 时,打印的sql语句不全 HOT 2
- JSqlParser4.8 HOT 1
- 如何兼容MybatisPlus 3.5.5 和 PageHelper 2.1.0 ? HOT 7
- make PageInfo implement Collection, and then can use it as a List directly HOT 1
- 开启异步count支持后,不兼容Mybatis-Plus的多租户插件 HOT 4
- springboot3.2.2引入pageHelper5.3.2执行分页方法报类型转换异常。分页不生效
- 开发者福利,尽快尝试领取!StarkNet针对TOP 5K进行空投!
- pagehelper在docker中卡在了启动欢迎处 HOT 1
- sqlserver 使用 PageHelper.startPage 分页报错 HOT 3
- 数据查询返回后进行转化,hasNextPage属性值永远是false HOT 3
- 升级到6.1.0后jsqlparser4.7又出问题了 HOT 2
- 版本由4.1.6 升级到5.3.2后,PageDynamicSqlSource被删除了有什么方案代替 HOT 1
- PageHelper6.1.0搭配jsqlparser4.5又出问题了
- springboot 3 整合 pagehelper 报错 Caused by: java.lang.NoClassDefFoundError: net/sf/jsqlparser/statement/select/SelectBody HOT 2
- sqlparser-timeout超时时间好像不是10秒 HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from mybatis-pagehelper.