We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
因多个服务都部署在同一台机器上,导致数据库主键生成重复,全局配置了 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()); } 也不生效,这种情况 怎么配置呢?
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
The text was updated successfully, but these errors were encountered:
你的问题是什么,是自定义id生成器无法生效?
Sorry, something went wrong.
No branches or pull requests
确认
功能改进
因多个服务都部署在同一台机器上,导致数据库主键生成重复,全局配置了 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
The text was updated successfully, but these errors were encountered: