SpringBoot使用分页插件报错 java.lang.IllegalStateException: Failed to introspect Class [com.github...

  • 今天在学习SpringBoot整合MyBatis使用PageHelper插件时出现这样一个错误
java.lang.IllegalStateException: Failed to introspect Class [com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@18b4aac2]
    at org.springframework.util.ReflectionUtils.getDeclaredFields(ReflectionUtils.java:758) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:723) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.util.ReflectionUtils.doWithFields(ReflectionUtils.java:708) ~[spring-core-5.0.8.RELEASE.jar:5.0.8.RELEASE]
    at org.springframework.boot.test.mock.mockito.DefinitionsParser.parse(DefinitionsParser.java:62) ~[spring-boot-test-2.0.4.RELEASE.jar:2.0.4.RELEASE]
    at org.springframework.boot.test.mock.mockito.MockitoPostProcessor.postProcessBeanFactory(MockitoPostProcessor.java:139) ~[spring-boot-test-2.0.4.RELEASE.jar:2.0.4.RELEASE]
......

把错误拉到最后之后是这样一个错误

Caused by: java.lang.ClassNotFoundException: org.springframework.boot.bind.RelaxedPropertyResolver
    at java.net.URLClassLoader.findClass(URLClassLoader.java:381) ~[na:1.8.0_111]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424) ~[na:1.8.0_111]
    at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:331) ~[na:1.8.0_111]
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357) ~[na:1.8.0_111]
    ... 43 common frames omitted
  • 是因为SpringBoot和pagehelper插件的版本冲突问题 我之前使用的是SpringBoot2.0.4和pagehelper1.1.0
  • pagehelper版本太低 所以要么把springboot也改成和pagehelper一样的版本 要么把pagehelper升级版本 下面两种版本搭配本人亲测没有冲突

1.把SpringBoot改成1.5.2版本


    org.springframework.boot
    spring-boot-starter-parent
    1.5.2.RELEASE
     


    
        com.github.pagehelper
        pagehelper-spring-boot-starter
        1.1.0
    

2.把pagehelper升级成1.2.7版本


    org.springframework.boot
    spring-boot-starter-parent
    2.0.4.RELEASE
     


    
        com.github.pagehelper
        pagehelper-spring-boot-starter
        1.2.7
    

你可能感兴趣的:(SpringBoot使用分页插件报错 java.lang.IllegalStateException: Failed to introspect Class [com.github...)