关于:Caused by: com.github.pagehelper.PageException: java.lang.ClassNotFoundException: mysql
·
Caused by: com.github.pagehelper.PageException: java.lang.ClassNotFoundException: mysql
场景复现:
在Spring Boot 2.3整合PageHelper时,依赖如下:
spring boot 2.3
pagehelper 1.3
mybaits-spring-boot -starter 2.1.3
结果启动时报错:
"C:\Program Files\Java\jdk1.8.0_261\bin\java.exe" -XX:TieredStopAtLevel=1 -noverify -Dspring.output.ansi.enabled=always -Dcom.sun.management.jmxremote -Dspring.jmx.enabled=true -Dspring.liveBeansView.mbeanDomain -Dspring.application.admin.enabled=true "-javaagent:D:\idea2020install\IntelliJ IDEA 2020.1\lib\idea_rt.jar=6064:D:\idea2020install\IntelliJ IDEA 2020.1\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files\Java\jdk1.8.0_261\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\cldrdata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\jfxrt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\nashorn.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\sunpkcs11.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\ext\zipfs.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jce.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jfxswt.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\resources.jar;C:\Program Files\Java\jdk1.8.0_261\jre\lib\rt.jar;D:\idea2020install\idea2020workspace\testprojectdemo\target\classes;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\mybatis\generator\mybatis-generator-core\1.3.5\mybatis-generator-core-1.3.5.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-data-redis\2.3.1.RELEASE\spring-boot-starter-data-redis-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter\2.3.1.RELEASE\spring-boot-starter-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-logging\2.3.1.RELEASE\spring-boot-starter-logging-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\ch\qos\logback\logback-classic\1.2.3\logback-classic-1.2.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\ch\qos\logback\logback-core\1.2.3\logback-core-1.2.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\apache\logging\log4j\log4j-to-slf4j\2.13.3\log4j-to-slf4j-2.13.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\apache\logging\log4j\log4j-api\2.13.3\log4j-api-2.13.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\slf4j\jul-to-slf4j\1.7.30\jul-to-slf4j-1.7.30.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\jakarta\annotation\jakarta.annotation-api\1.3.5\jakarta.annotation-api-1.3.5.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\yaml\snakeyaml\1.26\snakeyaml-1.26.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\data\spring-data-redis\2.3.1.RELEASE\spring-data-redis-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\data\spring-data-keyvalue\2.3.1.RELEASE\spring-data-keyvalue-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\data\spring-data-commons\2.3.1.RELEASE\spring-data-commons-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-tx\5.2.7.RELEASE\spring-tx-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-oxm\5.2.7.RELEASE\spring-oxm-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-aop\5.2.7.RELEASE\spring-aop-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-context-support\5.2.7.RELEASE\spring-context-support-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\slf4j\slf4j-api\1.7.30\slf4j-api-1.7.30.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\lettuce\lettuce-core\5.3.1.RELEASE\lettuce-core-5.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-common\4.1.50.Final\netty-common-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-handler\4.1.50.Final\netty-handler-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-resolver\4.1.50.Final\netty-resolver-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-buffer\4.1.50.Final\netty-buffer-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-codec\4.1.50.Final\netty-codec-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\netty\netty-transport\4.1.50.Final\netty-transport-4.1.50.Final.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\io\projectreactor\reactor-core\3.3.6.RELEASE\reactor-core-3.3.6.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\reactivestreams\reactive-streams\1.0.3\reactive-streams-1.0.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\github\pagehelper\pagehelper-spring-boot-starter\1.3.0\pagehelper-spring-boot-starter-1.3.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\github\pagehelper\pagehelper-spring-boot-autoconfigure\1.3.0\pagehelper-spring-boot-autoconfigure-1.3.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\github\pagehelper\pagehelper\5.2.0\pagehelper-5.2.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\github\jsqlparser\jsqlparser\3.2\jsqlparser-3.2.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-web\2.3.1.RELEASE\spring-boot-starter-web-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-json\2.3.1.RELEASE\spring-boot-starter-json-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\core\jackson-databind\2.11.0\jackson-databind-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\core\jackson-annotations\2.11.0\jackson-annotations-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\core\jackson-core\2.11.0\jackson-core-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jdk8\2.11.0\jackson-datatype-jdk8-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\datatype\jackson-datatype-jsr310\2.11.0\jackson-datatype-jsr310-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\fasterxml\jackson\module\jackson-module-parameter-names\2.11.0\jackson-module-parameter-names-2.11.0.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-tomcat\2.3.1.RELEASE\spring-boot-starter-tomcat-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\apache\tomcat\embed\tomcat-embed-core\9.0.36\tomcat-embed-core-9.0.36.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\glassfish\jakarta.el\3.0.3\jakarta.el-3.0.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\apache\tomcat\embed\tomcat-embed-websocket\9.0.36\tomcat-embed-websocket-9.0.36.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-web\5.2.7.RELEASE\spring-web-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-beans\5.2.7.RELEASE\spring-beans-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-webmvc\5.2.7.RELEASE\spring-webmvc-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-context\5.2.7.RELEASE\spring-context-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-expression\5.2.7.RELEASE\spring-expression-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\mybatis\spring\boot\mybatis-spring-boot-starter\2.1.3\mybatis-spring-boot-starter-2.1.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-starter-jdbc\2.3.1.RELEASE\spring-boot-starter-jdbc-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\com\zaxxer\HikariCP\3.4.5\HikariCP-3.4.5.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-jdbc\5.2.7.RELEASE\spring-jdbc-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\mybatis\spring\boot\mybatis-spring-boot-autoconfigure\2.1.3\mybatis-spring-boot-autoconfigure-2.1.3.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\mybatis\mybatis\3.5.5\mybatis-3.5.5.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\mybatis\mybatis-spring\2.0.5\mybatis-spring-2.0.5.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\mysql\mysql-connector-java\8.0.20\mysql-connector-java-8.0.20.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\projectlombok\lombok\1.18.12\lombok-1.18.12.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-core\5.2.7.RELEASE\spring-core-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\spring-jcl\5.2.7.RELEASE\spring-jcl-5.2.7.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot-autoconfigure\2.3.1.RELEASE\spring-boot-autoconfigure-2.3.1.RELEASE.jar;D:\apache-maven-3.6.2-bin\apache-maven-3.6.2\repository\org\springframework\boot\spring-boot\2.3.1.RELEASE\spring-boot-2.3.1.RELEASE.jar" cn.jbit.TestprojectdemoApplication
. ____ _ __ _ _
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
' |____| .__|_| |_|_| |_\__, | / / / /
=========|_|==============|___/=/_/_/_/
:: Spring Boot :: (v2.3.1.RELEASE)
2020-10-26 22:44:12.691 INFO 25332 --- [ main] cn.jbit.TestprojectdemoApplication : Starting TestprojectdemoApplication on PC1 with PID 25332 (D:\idea2020install\idea2020workspace\testprojectdemo\target\classes started by 张在成 in D:\idea2020install\idea2020workspace)
2020-10-26 22:44:12.712 INFO 25332 --- [ main] cn.jbit.TestprojectdemoApplication : No active profile set, falling back to default profiles: default
2020-10-26 22:44:15.087 INFO 25332 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Multiple Spring Data modules found, entering strict repository configuration mode!
2020-10-26 22:44:15.092 INFO 25332 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Bootstrapping Spring Data Redis repositories in DEFAULT mode.
2020-10-26 22:44:15.165 INFO 25332 --- [ main] .s.d.r.c.RepositoryConfigurationDelegate : Finished Spring Data repository scanning in 34ms. Found 0 Redis repository interfaces.
2020-10-26 22:44:16.663 INFO 25332 --- [ main] o.s.b.w.embedded.tomcat.TomcatWebServer : Tomcat initialized with port(s): 8080 (http)
2020-10-26 22:44:16.691 INFO 25332 --- [ main] o.apache.catalina.core.StandardService : Starting service [Tomcat]
2020-10-26 22:44:16.691 INFO 25332 --- [ main] org.apache.catalina.core.StandardEngine : Starting Servlet engine: [Apache Tomcat/9.0.36]
2020-10-26 22:44:16.999 INFO 25332 --- [ main] o.a.c.c.C.[Tomcat].[localhost].[/] : Initializing Spring embedded WebApplicationContext
2020-10-26 22:44:17.000 INFO 25332 --- [ main] w.s.c.ServletWebServerApplicationContext : Root WebApplicationContext: initialization completed in 4128 ms
2020-10-26 22:44:17.012 TRACE 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Added existing Servlet initializer bean 'dispatcherServletRegistration'; order=2147483647, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/DispatcherServletAutoConfiguration$DispatcherServletRegistrationConfiguration.class]
2020-10-26 22:44:17.045 TRACE 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'characterEncodingFilter'; order=-2147483648, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/HttpEncodingAutoConfiguration.class]
2020-10-26 22:44:17.045 TRACE 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'formContentFilter'; order=-9900, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration.class]
2020-10-26 22:44:17.045 TRACE 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Created Filter initializer for bean 'requestContextFilter'; order=-105, resource=class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$WebMvcAutoConfigurationAdapter.class]
2020-10-26 22:44:17.061 DEBUG 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Mapping filters: characterEncodingFilter urls=[/*] order=-2147483648, formContentFilter urls=[/*] order=-9900, requestContextFilter urls=[/*] order=-105
2020-10-26 22:44:17.062 DEBUG 25332 --- [ main] o.s.b.w.s.ServletContextInitializerBeans : Mapping servlets: dispatcherServlet urls=[/]
2020-10-26 22:44:18.209 INFO 25332 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Initializing ExecutorService 'applicationTaskExecutor'
2020-10-26 22:44:18.232 DEBUG 25332 --- [ main] s.w.s.m.m.a.RequestMappingHandlerAdapter : ControllerAdvice beans: 0 @ModelAttribute, 0 @InitBinder, 1 RequestBodyAdvice, 1 ResponseBodyAdvice
2020-10-26 22:44:18.331 TRACE 25332 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
c.j.s.u.c.UserController:
{GET /result}: getUserInfo()
{GET /result1}: getUserInfo1()
{GET /getUserByOther}: getUserByOther(User,HttpServletRequest)
2020-10-26 22:44:18.341 TRACE 25332 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping :
o.s.b.a.w.s.e.BasicErrorController:
{ /error}: error(HttpServletRequest)
{ /error, produces [text/html]}: errorHtml(HttpServletRequest,HttpServletResponse)
2020-10-26 22:44:18.345 DEBUG 25332 --- [ main] s.w.s.m.m.a.RequestMappingHandlerMapping : 5 mappings in 'requestMappingHandlerMapping'
2020-10-26 22:44:18.372 DEBUG 25332 --- [ main] o.s.w.s.h.BeanNameUrlHandlerMapping : Detected 0 mappings in 'beanNameHandlerMapping'
2020-10-26 22:44:18.402 TRACE 25332 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped [/webjars/**] onto ResourceHttpRequestHandler ["classpath:/META-INF/resources/webjars/"]
2020-10-26 22:44:18.403 TRACE 25332 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Mapped [/**] onto ResourceHttpRequestHandler ["classpath:/META-INF/resources/", "classpath:/resources/", "classpath:/static/", "classpath:/public/", "/"]
2020-10-26 22:44:18.403 DEBUG 25332 --- [ main] o.s.w.s.handler.SimpleUrlHandlerMapping : Patterns [/webjars/**, /**] in 'resourceHandlerMapping'
2020-10-26 22:44:18.431 DEBUG 25332 --- [ main] .m.m.a.ExceptionHandlerExceptionResolver : ControllerAdvice beans: 0 @ExceptionHandler, 1 ResponseBodyAdvice
2020-10-26 22:44:18.577 WARN 25332 --- [ main] ConfigServletWebServerApplicationContext : Exception encountered during context initialization - cancelling refresh attempt: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Invocation of init method failed; nested exception is com.github.pagehelper.PageException: java.lang.ClassNotFoundException: mysql
2020-10-26 22:44:18.577 INFO 25332 --- [ main] o.s.s.concurrent.ThreadPoolTaskExecutor : Shutting down ExecutorService 'applicationTaskExecutor'
2020-10-26 22:44:18.583 INFO 25332 --- [ main] o.apache.catalina.core.StandardService : Stopping service [Tomcat]
2020-10-26 22:44:18.602 INFO 25332 --- [ main] ConditionEvaluationReportLoggingListener :
Error starting ApplicationContext. To display the conditions report re-run your application with 'debug' enabled.
2020-10-26 22:44:18.622 ERROR 25332 --- [ main] o.s.boot.SpringApplication : Application run failed
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Invocation of init method failed; nested exception is com.github.pagehelper.PageException: java.lang.ClassNotFoundException: mysql
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:160) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.applyBeanPostProcessorsBeforeInitialization(AbstractAutowireCapableBeanFactory.java:416) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.initializeBean(AbstractAutowireCapableBeanFactory.java:1788) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.doCreateBean(AbstractAutowireCapableBeanFactory.java:595) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.createBean(AbstractAutowireCapableBeanFactory.java:517) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.lambda$doGetBean$0(AbstractBeanFactory.java:323) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultSingletonBeanRegistry.getSingleton(DefaultSingletonBeanRegistry.java:226) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.doGetBean(AbstractBeanFactory.java:321) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.AbstractBeanFactory.getBean(AbstractBeanFactory.java:202) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.support.DefaultListableBeanFactory.preInstantiateSingletons(DefaultListableBeanFactory.java:893) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.finishBeanFactoryInitialization(AbstractApplicationContext.java:879) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.context.support.AbstractApplicationContext.refresh(AbstractApplicationContext.java:551) ~[spring-context-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.boot.web.servlet.context.ServletWebServerApplicationContext.refresh(ServletWebServerApplicationContext.java:143) ~[spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:758) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refresh(SpringApplication.java:750) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.refreshContext(SpringApplication.java:397) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:315) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1237) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at org.springframework.boot.SpringApplication.run(SpringApplication.java:1226) [spring-boot-2.3.1.RELEASE.jar:2.3.1.RELEASE]
at cn.jbit.TestprojectdemoApplication.main(TestprojectdemoApplication.java:12) [classes/:na]
Caused by: com.github.pagehelper.PageException: java.lang.ClassNotFoundException: mysql
at com.github.pagehelper.PageInterceptor.setProperties(PageInterceptor.java:179) ~[pagehelper-5.2.0.jar:na]
at com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration.addPageInterceptor(PageHelperAutoConfiguration.java:81) ~[pagehelper-spring-boot-autoconfigure-1.3.0.jar:na]
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_261]
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_261]
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_261]
at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_261]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleElement.invoke(InitDestroyAnnotationBeanPostProcessor.java:389) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor$LifecycleMetadata.invokeInitMethods(InitDestroyAnnotationBeanPostProcessor.java:333) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
at org.springframework.beans.factory.annotation.InitDestroyAnnotationBeanPostProcessor.postProcessBeforeInitialization(InitDestroyAnnotationBeanPostProcessor.java:157) ~[spring-beans-5.2.7.RELEASE.jar:5.2.7.RELEASE]
... 19 common frames omitted
Caused by: java.lang.ClassNotFoundException: mysql
at java.net.URLClassLoader.findClass(URLClassLoader.java:382) ~[na:1.8.0_261]
at java.lang.ClassLoader.loadClass(ClassLoader.java:418) ~[na:1.8.0_261]
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:355) ~[na:1.8.0_261]
at java.lang.ClassLoader.loadClass(ClassLoader.java:351) ~[na:1.8.0_261]
at java.lang.Class.forName0(Native Method) ~[na:1.8.0_261]
at java.lang.Class.forName(Class.java:264) ~[na:1.8.0_261]
at com.github.pagehelper.PageInterceptor.setProperties(PageInterceptor.java:176) ~[pagehelper-5.2.0.jar:na]
... 27 common frames omitted
Process finished with exit code 1
解决途径:通过debug源码,发现配置文件读取到的是“mysql”,而源码中需要的是一个类的全类名来反射,所以推断这个属性值不是mysql,而是一个全类名。
解决方案:
配置文件properties需要改动一下,将原来的
pagehelper.helperDialect=mysql
改为:
pagehelper.dialect=com.github.pagehelper.dialect.helper.MySqlDialect
附上pagehelper和spring boot/mybatis整合时版本要求(详见以下官网):
https://github.com/pagehelper/pagehelper-spring-boot
补充说明:
整合过程中,各个版本的依赖最好依赖官网给出的建议(会少采很多坑!!!)
看源码的乐趣!!!! 通过看源码解决了这个问题!!!加油!!!
更多推荐
已为社区贡献3条内容
所有评论(0)