使用mybatis plus常见错误

问题描述

  • 错误1:代码生成器依赖和mybatis依赖冲突
  • 启动项目时报错如下
2021-12-03 13:33:33.927 ERROR 7228 --- [           main] o.s.b.d.LoggingFailureAnalysisReporter   : 

***************************
APPLICATION FAILED TO START
***************************

Description:

An attempt was made to call a method that does not exist. The attempt was made from the following location:

    org.mybatis.spring.SqlSessionFactoryBean.buildSqlSessionFactory(SqlSessionFactoryBean.java:564)

The following method did not exist:

    org.apache.ibatis.session.Configuration.setDefaultEnumTypeHandler(Ljava/lang/Class;)V

The method's class, org.apache.ibatis.session.Configuration, is available from the following locations:

    jar:file:/C:/repo/maven/org/mybatis/mybatis/3.4.4/mybatis-3.4.4.jar!/org/apache/ibatis/session/Configuration.class

The class hierarchy was loaded from the following locations:

    org.apache.ibatis.session.Configuration: file:/C:/repo/maven/org/mybatis/mybatis/3.4.4/mybatis-3.4.4.jar
  • 错误原因:如下代码生成器依赖mybatis依赖冲突
  <dependency>
      <groupId>org.mybatis</groupId>
      <artifactId>mybatis</artifactId>
      <version>3.4.4</version>
  </dependency>
  <!-- mybatis-generator-core 反向生成java代码-->
  <dependency>
      <groupId>org.mybatis.generator</groupId>
      <artifactId>mybatis-generator-core</artifactId>
      <version>1.3.5</version>
  </dependency>
————————————————————————————————————————————————————
  <dependency>
      <groupId>org.mybatis.spring.boot</groupId>
      <artifactId>mybatis-spring-boot-starter</artifactId>
      <version>1.3.2</version>
  </dependency>
  <dependency>
      <groupId>com.alibaba</groupId>
      <artifactId>druid-spring-boot-starter</artifactId>
      <version>1.1.10</version>
  </dependency>
  • 错误2:org.apache.ibatis.binding.BindingException: Invalid bound statement (not found)
# 参考:https://cloud.tencent.com/developer/article/1896205
# 错误原因:interface与xml不能对应
# 我这里的报错原因是因为ddd项目中xml映射文件放在domain路径下,将xml放到resource路径下可解决

# 错误还原2:cloud + ddd 项目中报错,xml映射文件放在com.chnq.provide.domain.repository.mapper.xml路径下
# 参考:https://www.cnblogs.com/itzyz/p/10954427.html
# 解决方案:在子模块的pom中配置如下,自动扫描xml
<resources>
    <resource>
        <directory>src/main/java</directory>
        <includes>
            <include>**/*.xml</include>
        </includes>
    </resource>
</resources>
  • 错误3:org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'deptsController': Unsatisfied dependency expressed through field 'deptService';
项目详情:cloud项目的子模块使用mybatis,之后又集成了mybatis plus,
错误原因1:项目中有多个实体类文件夹,https://blog.csdn.net/csdn_tingou/article/details/84872046
错误原因2:包名实现类等是否正确,https://blog.csdn.net/qq_41581154/article/details/101123221?ops_request_misc=&request_id=&biz_id=102&utm_term=org.springframework.beans.fact&utm_medium=distribute.pc_search_result.none-task-blog-2~all~sobaiduweb~default-0-101123221.nonecase&spm=1018.2226.3001.4187

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

依赖报错 idea导入项目后依赖报错,解决方案:https://blog....
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下...
错误1:gradle项目控制台输出为乱码 # 解决方案:https://bl...
错误还原:在查询的过程中,传入的workType为0时,该条件不起...
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct...