## Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
### The error may involve com.atguigu.gmall.manage.mapper.PmsBaseAttrValueMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO pms_base_attr_value ( id,value_name,attr_id ) VALUES( ?,?,? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
; SQL []; Duplicate entry '219' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
org.springframework.dao.DuplicateKeyException:
### Error updating database. Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
### The error may involve com.atguigu.gmall.manage.mapper.PmsBaseAttrValueMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO pms_base_attr_value ( id,value_name,attr_id ) VALUES( ?,?,? )
### Cause: com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
; SQL []; Duplicate entry '219' for key 'PRIMARY'; nested exception is com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException: Duplicate entry '219' for key 'PRIMARY'
at org.springframework.jdbc.support.SQLErrorCodeSQLExceptionTranslator.doTranslate(SQLErrorCodeSQLExceptionTranslator.java:239)
springboot+mybatis com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException异常解决方案
最新推荐文章于 2024-05-12 15:44:07 发布
在尝试使用SpringBoot和MyBatis插入数据时遇到MySQL的IntegrityConstraintViolationException,错误提示为Duplicate entry '219' for key 'PRIMARY'。问题出在尝试插入已存在的主键值。解决方案是在模型类中添加@GeneratedValue(strategy = GenerationType.IDENTITY)注解,允许数据库自增主键。
摘要由CSDN通过智能技术生成