Mybatis出现报错Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index 15 out of xxx

Mybatis出现报错Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index 15 out of xxx

报错详情

[Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.exceptions.PersistenceException:
### Error querying database. Cause: java.lang.IndexOutOfBoundsException: Index: x, Size: x

报错原因

实体类中缺失了无参构造方法,当前实体类只使用了 @Data和@Builder,当使用了@Builder注解时,该实体类将不再提供无参构造方法,而Mybatis在sql执行完进行返回结果时,要使用该返回类的无参构造创建对象。最终导致出现异常

解决方案

在实体类增加注解@NoArgsConstructor@AllArgsConstructor,使编译器编译的时候提供出无参构造。

© 版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容