mybatis显示IndexOutOfBoundsException、日志规范、There is no getter for property named ‘xxx‘ in ‘class xxx

### Error querying database.  Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2
### The error may exist in file [D:\生态组件\hzero-ocr\hzero-ocr\target\classes\mapper\AccountRelTenantMapper.xml]
### The error may involve org.hzero.ocr.infra.mapper.AccountRelTenantMapper.getTenantsNotInRel
### The error occurred while handling results

Cause: java.lang.IndexOutOfBoundsException: Index: 2, Size: 2

解决方式:

 原因: @Builder注解使用后我们必须显式的声明构造方法,或者使用@AllArgsConstructor @NoArgsConstructor来声明构造。

 这异常是mybatisplus和lombok冲突造成的,mybatis找不到构造方法,无法将查询结果绑定到实体对象上。

解决:

返回的实体类上增加

@AllArgsConstructor
@NoArgsConstructor


 

增加日志的规范:

将info 修改为下图的debug,debug是最低的触发日志的级别

There is no getter for property named 'xxx' in 'class xxx 的解决办法

错误原因之一:

在mybtis的<where>查询中,使用了account,如果不添加注解说明的话,mybatis只会接受到accountBuild。就会导致no getter的错误

猜你喜欢

转载自blog.csdn.net/awodwde/article/details/121274577