问题:当使用mybatis-plus在启动时出现以下错误
java.lang.IllegalStateException: Failed to introspect Class [com.baomidou.mybatisplus.autoconfigure.MybatisPlusAutoConfiguration] from ClassLoader [sun.misc.Launcher$AppClassLoader@14dad5dc]
Caused by: java.lang.NoClassDefFoundError: com/baomidou/mybatisplus/extension/spring/MybatisSqlSessionFactoryBean
at java.lang.Class.getDeclaredMethods0(Native Method) ~[na:1.8.0_51]
at java.lang.Class.privateGetDeclaredMethods(Class.java:2701) ~[na:1.8.0_51]
at java.lang.Class.getDeclaredMethods(Class.java:1975) ~[na:1.8.0_51]
at org.springframework.util.ReflectionUtils.getDeclaredMethods(ReflectionUtils.java:668) ~[spring-core-5.1.5.RELEASE.jar:5.1.5.RELEASE]
… 22 common frames omitted
Caused by: java.lang.ClassNotFoundException: com.baomidou.mybatisplus.extension.spring.MybatisSqlSessionFactoryBean
基本上可以定位为依赖的问题,由于使用的是mybatis-plus,所以将依赖的mybatis删掉!
比如,我的项目里,我分成了三个模块(api service common),

我在最外层 pom.xml已经依赖mybatis-plus,亦在common模块中依赖mybatis

把mybatis删掉,并把依赖的mybatis-plus-boot-starter删掉!

(我的spring boot是 2.1.3.RELEASE ,出现该问题估计是mybatis-plus 3.1.0的bug)
本文解决Mybatis-Plus在SpringBoot项目中启动时出现的ClassNotFoundException问题,通过删除重复的Mybatis依赖并调整mybatis-plus-boot-starter版本,避免与Mybatis-Plus冲突。
1338

被折叠的 条评论
为什么被折叠?



