展开
拓展 关闭
订阅号推广码
GitHub
视频
公告栏 关闭

使用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
posted @   DogLeftover  阅读(253)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 阿里巴巴 QwQ-32B真的超越了 DeepSeek R-1吗?
· 10年+ .NET Coder 心语 ── 封装的思维:从隐藏、稳定开始理解其本质意义
· 【设计模式】告别冗长if-else语句:使用策略模式优化代码结构
· 字符编码:从基础到乱码解决
· 提示词工程——AI应用必不可少的技术
历史上的今天:
2021-07-22 ubuntu入门
点击右上角即可分享
微信分享提示