版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
严重: 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方法。