数据插入成功了,但是报错

来源:4-1 Dao层之新增店铺

派大星不吃海星

2021-02-18

老师你好,为了更好的理解,我把相关shop的改为了library,把product改为了book,这是我的报错,相关数据已经插入,但是还是报这个错,这个怎么办,看百度的没看懂
org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty ‘LibraryId’ in ‘com.hg.entity.Library’.

at org.springframework.test.context.junit4.statements.RunBeforeTestMethodCallbacks.evaluate(RunBeforeTestMethodCallbacks.java:75)
at org.springframework.test.context.junit4.statements.RunAfterTestMethodCallbacks.evaluate(RunAfterTestMethodCallbacks.java:86)

at org.springframework.test.context.junit4.statements.RunBeforeTestClassCallbacks.evaluate(RunBeforeTestClassCallbacks.java:61)
at org.springframework.test.context.junit4.statements.RunAfterTestClassCallbacks.evaluate(RunAfterTestClassCallbacks.java:70)

Caused by: org.apache.ibatis.executor.ExecutorException: Error getting generated key or setting result to parameter object. Cause: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty ‘LibraryId’ in ‘com.hg.entity.Library’.

Caused by: org.apache.ibatis.executor.ExecutorException: No setter found for the keyProperty ‘LibraryId’ in ‘com.hg.entity.Library’.

写回答

2回答

翔仔

2021-02-19

同学好,我看异常是首字母大写的LibraryId 同学看看配置文件里面,就是mybatis配置文件,是不是写成大写的了,应该是libraryId才对哈。。

https://blog.csdn.net/wuaidy/article/details/103764325


1
1
派大星不吃海星
是的。笑哭。里面的写了大写去了,谢谢老师
2021-02-21
共1条回复

翔仔

2021-02-18

同学好,这说的是LibraryId没有设置setLibraryId方法,需要在entity设置上。

0
1
派大星不吃海星
但是老师我的里面是有的。 public Long getLibraryId() { return libraryId; } public void setLibraryId(Long libraryId) { this.libraryId = libraryId; }
2021-02-19
共1条回复

Java双版本(SSM到SpringBoot)校园商铺全栈开发

SSM商铺V1.0,解决毕设痛点;SpringBoot商铺V2.0,满足工作刚需

5137 学习 · 8152 问题

查看课程