Mybatis报错“Field ‘id‘ doesn‘t have a default value”

Obviously the selectKey has been configured, but an error was reported, so I found it because the id in the table was not set to auto-increment. .

   @Insert({"insert into song(name,singer,category,writer,language,issudate)values(#{name},#{singer},#{category},#{writer},#{language},#{issudate})"
    })
    @SelectKey(statement = "select last_insert_id()",before = false, resultType = Integer.class,keyProperty = "id")
    public int insert(Songs songs);
}

Guess you like

Origin blog.csdn.net/qq_36792120/article/details/112550983