canal 同步表数据提示java.lang.RuntimeException: Target column: id not matched

canal版本为:1.1.4

canal 同步表数据提示java.lang.RuntimeException: Target column: id not matched

主要原因是源主键id和目标主键id不匹配,如果我们的主键id字段名不是id,假如为xx_id,那么对于的配置应如下:

dataSourceKey: defaultDS
destination: example
groupId: g1
outerAdapterKey: mysql1
concurrent: true
dbMapping:
  database: mytest
  table: user
  targetTable: mytest2.user
  targetPk:
    xx_id: xx_id
#  mapAll: true
  targetColumns:
    id:
    name:
    role_id:
    c_time:
    test1:
  etlCondition: "where c_time>={}"
  commitBatch: 3000 # 批量提交的大小

这个错误网上找了一圈都没发现,还是看源码发现的,这设计真是牛了,就不能单独拿一个源主键id的字段出来吗?如sourcePk.id吗?直接用了targetPk.{id}这个{id}就是源主键id的列名,如源主键列名为xx_id,那么这个地方就应为targetPk.xx_id,对应的目标端的主键id为xx_id,则targetPk.xx_id=xx_id,666

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 5
    评论
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值