@SnowId()
New in 2.0Generate Snowflake-based IDs (distributed unique)
ID GenerationSince 2.0.0
Parameters
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
| dcId | Long | — | 1 | Datacenter ID, default 1 |
| mId | Long | — | 1 | Machine ID, default 1 |
Usage
@SnowId()Generate Snowflake ID (dcId=1, mId=1)
Example:
@SnowId()
Output:
16685359784@SnowId(dcId,mid)Generate Snowflake ID with specified dcId and mId
Example:
@SnowId(1,1)
Output:
16685359784