请稍等 ...
×

采纳答案成功!

向帮助你的同学说点啥吧!感谢那些助人为乐的人

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

老师你好,为了更好的理解,我把相关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回答

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

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


1 回复 有任何疑惑可以回复我~
  • 提问者 派大星不吃海星 #1
    是的。笑哭。里面的写了大写去了,谢谢老师
    回复 有任何疑惑可以回复我~ 2021-02-21 14:25:52
翔仔 2021-02-18 22:45:49

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

0 回复 有任何疑惑可以回复我~
  • 提问者 派大星不吃海星 #1
    但是老师我的里面是有的。
    public Long getLibraryId() {
    			return libraryId;
    		}
    		public void setLibraryId(Long libraryId) {
    			this.libraryId = libraryId;
    		}
    回复 有任何疑惑可以回复我~ 2021-02-19 10:19:21
问题已解决,确定采纳
还有疑问,暂不采纳
微信客服

购课补贴
联系客服咨询优惠详情

帮助反馈 APP下载

慕课网APP
您的移动学习伙伴

公众号

扫描二维码
关注慕课网微信公众号