Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[功能改进]: 描述 主键重复问题 #6641

Open
3 tasks done
350078238 opened this issue Dec 21, 2024 · 1 comment
Open
3 tasks done

[功能改进]: 描述 主键重复问题 #6641

350078238 opened this issue Dec 21, 2024 · 1 comment

Comments

@350078238
Copy link

确认

  • 我的版本是最新版本, 我的版本号与 version 相同, 并且项目里无依赖冲突
  • 我已经在 issue 中搜索过, 确认问题没有被提出过
  • 我已经修改标题, 将标题中的 描述 替换为遇到的问题

功能改进

因多个服务都部署在同一台机器上,导致数据库主键生成重复,全局配置了 id-type: assign_id,并且 尝试了官方的 public class CustomIdGenerator implements IdentifierGenerator { @Override public Long nextId(Object entity) { // 使用实体类名作为业务键,或者提取参数生成业务键 String bizKey = entity.getClass().getName(); // 根据业务键调用分布式ID生成服务 long id = 123456; // 调用分布式ID生成逻辑 // 返回生成的ID值 return id; } } @Bean public MybatisPlusPropertiesCustomizer plusPropertiesCustomizer() { return plusProperties -> plusProperties.getGlobalConfig().setIdentifierGenerator(new CustomIdGenerator()); } 也不生效,这种情况 怎么配置呢?

参考资料

No response

@nieqiurong
Copy link
Contributor

你的问题是什么,是自定义id生成器无法生效?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants