baomidou / mybatis-plus

An powerful enhanced toolkit of MyBatis for simplify development
https://baomidou.com
Apache License 2.0
16.3k stars 4.3k forks source link

springboot分层多模块+mybatisplus启动报错 #1292

Closed dingxudong2017 closed 5 years ago

dingxudong2017 commented 5 years ago

当前使用版本(必须填写清楚,否则不予处理)

mybatis plus 3.1.1

该问题是怎么引起的?*([最新版](https://search.maven.org/search?q=g:com.baomidou%20a:mybatis-)上已修复的会直接close掉)**

springboot多模块分层架构(modules包含demo-common,demo-dao,demo-service,demo-web),父pom.xml packaging为pom,

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

项目架构的是springboot2.1.3.RELEASE+druid+mybatisPlus3.1.1

重现步骤

一直启动报错,不知道什么原因,可以新建一个springboot多模块分层架构重现问题: 项目是springboot多模块工程,父工程中就一个pom.xml packaging为pom,modules包含demo-common,demo-dao,demo-service,demo-web,子模块demo-common,demo-dao,demo-service packaging为jar,子模块demo-web packaging为war,在子模块demo-common,demo-dao,demo-service引入了mybatis plus 3.1.1,在子模块demo-common中新建了UserPo类: public class UserPo extends Model并加上了mybatis plus的注解@Table(value = "t_user")(其他成员变量字段也加了 @TableId(value = "user_id", type = IdType.AUTO) @TableField(value = "user_name")注解),在子模块demo-dao中新建接口UserMapper: public interface UserMapper extends BaseMapper 并加了@Mapper注解,在子模块demo-dao的resource目录下新建了mapper包并新建了UserMapper.xml文件里面就一个简单的mybatis查询语句,在子模块demo-service中新建接口UserService:public interface UserService extends IService,在impl包中新建UserServiceImpl实现类:public class UserServiceImpl extends ServiceImpl<UserMapper,UserPo> implements UserService,在application-dev.properties中设置了mybatis扫描的mapper.xml路径:mybatis.mapper-locations=classpath:mapper/Mapper.xml,数据库实体路径扫描也配置了:mybatis.type-aliases-package=com.example.demo.common,在application.properties中指定激活dev配置:spring.profiles.active=dev,springboot启动主类上面加了@MapperScan("com.example.demo.dao"),参考了mybatis plus官网的配置应该无遗漏,就是启动不了

报错信息

springboot多模块分层项目+mybatisPlus启动报错,报错信息如下: Description:

An attempt was made to call the method com.baomidou.mybatisplus.core.MybatisConfiguration.getLanguageDriver(Ljava/lang/Class;)Lorg/apache/ibatis/scripting/LanguageDriver; but it does not exist. Its class, com.baomidou.mybatisplus.core.MybatisConfiguration, is available from the following locations:

jar:file:/E:/idea_m2_my/repo/com/baomidou/mybatis-plus-core/3.1.1/mybatis-plus-core-3.1.1.jar!/com/baomidou/mybatisplus/core/MybatisConfiguration.class

It was loaded from the following location:

file:/E:/idea_m2_my/repo/com/baomidou/mybatis-plus-core/3.1.1/mybatis-plus-core-3.1.1.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.baomidou.mybatisplus.core.MybatisConfiguration

whh945atsyzx commented 5 years ago

遇到过,要把mybatis-spring-boot-starter升级到2.0.1

dingxudong2017 commented 5 years ago

遇到过,要把MyBatis的弹簧引导起动器升级到2.0.1

springboot的版本都是2.1.3.RELEASE

miemieYaho commented 5 years ago

自行排查,无法复现

dingxudong2017 commented 5 years ago

自行排查,无法复现

能否提供一个邮箱帮忙看看

dingxudong2017 commented 5 years ago

自行排查,无法复现

能否提供一个邮箱帮忙看看

已发送到ming.sansama@gmail.com 请帮忙看一下

miemieYaho commented 5 years ago

自己看你的mybatis 和 mybatis-spring 版本冲突,idea下载maven helper 看,eclipse就自己想办法

dingxudong2017 commented 5 years ago

自己看你的mybatis 和 mybatis-spring 版本冲突,idea下载maven helper 看,eclipse就自己想办法

感谢@miemieYaho的支持,使用maven helper插件解决了jar包冲突后可以正常使用了