mybatis报错org.mybatis.spring.MyBatisSystemException: nested exception is

版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接: https://blog.csdn.net/weixin_42571004/article/details/92126581

严重: Servlet.service() for servlet [mvc-dispatcher] in context with path [/medical-treatment-manage] threw exception [Request processing failed; nested exception is org.mybatis.spring.MyBatisSystemException: nested exception is org.apache.ibatis.executor.ExecutorException:No setter found for the keyProperty ‘materialScienceId’ in com.naturent.medical.entity.MaterialScience.
在mysql数据库使用mybatis插入数据时报错,可以清楚的看到“keyProperty”,在xml文件

<insert id="insert" parameterType="com.naturent.medical.entity.xxxx">
    <selectKey keyProperty="materialScienceId" order="AFTER" resultType="java.lang.Integer">
    SELECT LAST_INSERT_ID()
    </selectKey>

指的就是keyProperty的属性出错了,当前属性materialScienceId应该指向的是实体类materialscienceid,而不是数据库中的字段名materialScienceId,我这里表字段名为materialScienceId有大小写,而创建实体类是没有使用跟表名完全相同的,所有大小写问题报错,materialScienceId没有对应是set方法。

猜你喜欢

转载自blog.csdn.net/weixin_42571004/article/details/92126581