- 今天在學(xué)習(xí)SpringBoot整合MyBatis使用PageHelper插件時出現(xiàn)這樣一個錯誤
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版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>1.5.2.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.1.0</version>
</dependency>
</dependencies>
2.把pagehelper升級成1.2.7版本
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.0.4.RELEASE</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<dependencies>
<dependency>
<groupId>com.github.pagehelper</groupId>
<artifactId>pagehelper-spring-boot-starter</artifactId>
<version>1.2.7</version>
</dependency>
</dependencies>