在kafka发送消息到另一个service,service执行sql, 首次或前2次执行正常C操作,但后续2次或以后的操作必然发生以下错误:

### Error updating database.  Cause:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'
### The error may exist in
com/crossoverjie/kafka/orderconsumer/mapper/StockOrderMapper.java (best guess)
### The error may involve
com.crossoverjie.kafka.orderconsumer.mapper.StockOrderMapper.insertSelective-Inline
### The error occurred while setting parameters
### SQL: INSERT INTO stock_order  ( id,sid,name ) VALUES( ?,?,? )
### Cause:
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'
; SQL []; Duplicate entry '93' for key 'PRIMARY'; nested exception is
com.mysql.jdbc.exceptions.jdbc4.MySQLIntegrityConstraintViolationException:
Duplicate entry '93' for key 'PRIMARY'

2018-05-21 16:38:31.273 [consumer-pool-0] TRACE o.s.t.i.TransactionInterceptor
- Completing transaction for
[com.crossoverjie.kafka.orderconsumer.service.impl.OrderServiceImpl.createOptimisticOrderUseRedisAndKafka]
after exception: java.lang.RuntimeException: 

根据错误提示,说已存在主键id=93这条数据,不能再插入了,正常理解是93是已存在了,为啥新插入id自增的怎么没自动累加呢?

我们的pojo设置了主键id注解

去掉就好了

技术
©2019-2020 Toolsou All rights reserved,
Unity-Demo实例之 ✨ 实现UI-背包装备拖拽功能计算机网络---计算机网络基本概念(协议、体系)某东14薪变16薪,是诚意还是套路?让人意想不到的Python之樱花树(turtle库的华丽样式)java四大函数式接口(重点,简单)06【若依框架解读】数据范围过滤--太牛了Unity3D之UGUI基础--画布的三种模式os模块的简单使用html写樱花树,写樱花树的作文