Caused by: java.lang.NoSuchMethodException: com.github.pagehelper.autoconfigure.MapperAutoConfiguration$$EnhancerBySpringCGLIB$$70bd95a7.<init>()
Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [com.github.pagehelper.autoconfigure.MapperAutoConfiguration$$EnhancerBySpringCGLIB$$70bd95a7]: No default constructor found; nested exception is java.lang.NoSuchMethodException: com.github.pagehelper.autoconfigure.MapperAutoConfiguration$$EnhancerBySpringCGLIB$$70bd95a7.() at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:85) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1098) ... 22 more
本来我这几天在写starter,整合你的mapper和pagehelper的,元旦回来一看你竟然自己写了starter了,太惊喜了,所以直接用了你的,可是运行的时候出现了以上错误,能帮忙分析一下么,我自己之前写的配置是可以运行的。
Spring Boot 版本过低引起的,由于 Pagehelper 的 autoconfig 用了特殊的构造参数注入,需要 Spring Boot 版本高点。
稍后我会提供一个特别的0.1.0 版本支持低版本的 Spring Boot。
你使用的 Spring Boot 版本是多少?
我之前是使用的1.3.3Release
升级了1.4.3Release之后可以运行了,但是又出了另外一个错,在使用pagehelper的时候,
Error querying database. Cause: java.lang.NullPointerException
Cause: java.lang.NullPointerException] with root cause
java.lang.NullPointerException at java.util.concurrent.ConcurrentHashMap.get(ConcurrentHashMap.java:936) at java.util.concurrent.ConcurrentHashMap.containsKey(ConcurrentHashMap.java:964) at com.github.pagehelper.page.PageAutoDialect.getDialect(PageAutoDialect.java:192)
DataSource dataSource = ms.getConfiguration().getEnvironment().getDataSource();
String url = getUrl(dataSource);
if (urlDialectMap.containsKey(url)) {
return urlDialectMap.get(url);
}
DataSource是已经注入的,但是上述代码中的url取出来为空
调用方式如下: PageHelper.startPage(0,5); xxxMapper.selectAll();
PageHelper.startPage 中 pageNum 从 1 开始。。上面 url 的问题只能断点找原因。