数据插入成功了,但是报错
来源: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回答
-
同学好,我看异常是首字母大写的LibraryId 同学看看配置文件里面,就是mybatis配置文件,是不是写成大写的了,应该是libraryId才对哈。。
https://blog.csdn.net/wuaidy/article/details/103764325
112021-02-21 -
翔仔
2021-02-18
同学好,这说的是LibraryId没有设置setLibraryId方法,需要在entity设置上。
012021-02-19
相似问题