BindingException: Mapper method 'xxx.dao.StudentDao.insertStudent' attempted to return null from a method with a primitive return type (int).

一、问题

报错结果:

 二、造成错误代码

本人造成的错误是在 dao/StudentDao.xml 文件造成的,也就是持久层的dao配置文件写错了,下面是本人的错误代码:

    <select id="insertStudent">
        insert into student1(name, age) values (#{name}, #{age})
    </select>

造成错误的原因,这是新手容易犯的错误,将插入数据标签写成查询数据的标签,导致错误

 三、解决方法

正确代码

    <insert id="insertStudent">
        insert into student1(name, age) values (#{name}, #{age})
    </insert>

 

posted @ 2021-10-25 12:46  Erudite  阅读(149)  评论(0编辑  收藏  举报