/**
* 该类实现的功能是在strongUuidGenerator基础上,去除类'-'
*/
@Component
public class CustomUuidGenerator implements IdGenerator {
protected static volatile TimeBasedGenerator timeBasedGenerator;
public CustomUuidGenerator() {
ensureGeneratorInitialized();
}
protected void ensureGeneratorInitialized() {
if (timeBasedGenerator == null) {
synchronized (StrongUuidGenerator.class) {
if (timeBasedGenerator == null) {
timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface());
}
}
}
}
@Override
public String getNextId() {
//自己有需要可以在这里返回自定义生成的ID
return timeBasedGenerator.generate().toString().replaceAll("-","");
}
}
Camunda自定义ID生成器
最新推荐文章于 2023-11-29 08:54:06 发布