全局ID生成器
Shoulder
提供了两类开箱即用的全局id生成器:StringGuidGenerator
、LongGuidGenerator
,您可以像这样使用它们。
@Autowired
private StringGuidGenerator stringGuidGenerator;
@Autowired
private LongGuidGenerator longGuidGenerator;
public void testGuid() {
long guidLong = longGuidGenerator.nextId();
String guidString = stringGuidGenerator.nextId();
// 批量获取
long[] guidLongArr = longGuidGenerator.nextIds(10);
String[] guidStringArr = stringGuidGenerator.nextIds(10);
}