java.sql.SQLException: Field 'id' doesn't have a default value异常

在做mybatis插入的时候报了这个错误,百度了下,貌似是因为这个健没有设置值且不是自增类型的。

java.sql.SQLException: Field 'id' doesn't have a default value
    at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:965) ~[mysql-connector-java-5.1.46.jar:5.1.46]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3976) ~[mysql-connector-java-5.1.46.jar:5.1.46]
    at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3912) ~[mysql-connector-java-5.1.46.jar:5.1.46]
    at com.mysql.jdbc.MysqlIO.sendCommand(MysqlIO.java:2530) ~[mysql-connector-java-5.1.46.jar:5.1.46]

只有到数据库把这张表设置成自增类型的就ok了

 

posted @ 2018-09-08 12:49  测试5454  阅读(871)  评论(0编辑  收藏  举报