1
0
mirror of synced 2025-12-27 15:37:57 +08:00
Files
SnowFlake-IdGenerator/Java/README.md
2021-03-15 13:14:06 +08:00

29 lines
547 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
## 运行环境
JDK 1.8+
## 引用 maven 包
```
```
## 调用示例
```
// 全局初始化设置WorkerId默认最大2^16-1。初始化过程全局只需一次且必须最先设置
IdGeneratorOptions options = new IdGeneratorOptions();
options.WorkerId = 1;
YitIdHelper.setIdGenerator(options);
// 初始化以后就可以在需要的地方调用方法生成ID。
long newId = YitIdHelper.nextId();
```
如果基于DI框架集成可以参考 YitIdHelper 去管理 IdGenerator 对象,必须使用**单例**模式。
## options 默认值及说明
参考源码:/contract/IdGeneratorOptions.java