qq_35442885 2021-02-26 22:31 采纳率: 0%
浏览 1681

mybatis 为何我的id已经设置了主键自增,仍然报id不能为空?

//上图是表信息

//控制台错误信息

### Error updating database.  Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'id' cannot be null
### The error may exist in com/dun/mapper/AccountMapper.java (best guess)
### The error may involve com.dun.mapper.AccountMapper.save-Inline
### The error occurred while setting parameters
### SQL: insert into accounts values(?,?,?)
### Cause: java.sql.SQLIntegrityConstraintViolationException: Column 'id' cannot be null
; Column 'id' cannot be null; nested exception is java.sql.SQLIntegrityConstraintViolationException: Column 'id' cannot be null

//代码信息

public interface AccountMapper {

    @Insert("insert into accounts values(#{id},#{name},#{money})")
    public void save(Account account);

    @Select("select * from accounts")
    public List<Account> findAll();
}
  • 写回答

5条回答 默认 最新

  • 编号灬9527 2021-02-26 22:57
    关注

    看不住有自增 - -

    评论

报告相同问题?