首页 > 其他分享 >使用mybatis plus常见错误

使用mybatis plus常见错误

时间:2022-10-03 14:02:04浏览次数:61  
标签:xml 错误 ibatis apache 3.4 plus mybatis org

  • 错误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路径下
# 解决方案:在子模块的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:项目中有多个实体类文件夹,
错误原因2:包名实现类等是否正确



标签:xml,错误,ibatis,apache,3.4,plus,mybatis,org
From: https://blog.51cto.com/chniny/5730208

相关文章