当前使用版本(必填,否则不予处理)
3.3.1
该问题是如何引起的?(确定最新版也有问题再提!!!)
在分布式里面准确的来说是docker容器里面我几个服务使用的是同一个数据库, 但是在同一时间段就会出现id重复的问题 原因1:getDatacenterId是0L 在3.3.1版本或者说以上的版本是如何解决 worker-id和datacenter-id已经过时是不在全局配置里面了吗
重现步骤(如果有就写完整)
报错信息
Comment From: yanwencheng
问题解决了么,我也发现这个过时了,但不知道怎么配置
Comment From: ybbwk
从3.4.3的源码里看,虽然标为了已过时,但仍然使用这两个参数,
Comment From: qmdx
要学会看测试用例啊, 自行注入调整
@Bean
@ConditionalOnMissingBean
public IdentifierGenerator identifierGenerator() {
GlobalConfig globalConfig = properties.getGlobalConfig();
Long workerId = globalConfig.getWorkerId();
Long datacenterId = globalConfig.getDatacenterId();
if (workerId != null && datacenterId != null) {
return new DefaultIdentifierGenerator(workerId, datacenterId);
} else {
return new DefaultIdentifierGenerator(inetUtils.findFirstNonLoopbackAddress());
}
}