j-id 提供 依托redis/zookeeper确定机器序号,基于snowflake算法的分布式ID生成器。
● require jdk 1.8+
● require slf4j
<dependency>
<groupId>net.jrouter</groupId>
<artifactId>j-id</artifactId>
<version>1.4</version>
</dependency>
Sample application.properties
#id service properties (IdServiceProperties)
# default: true
net.jrouter.id.enable-local-file-storager=false
# default: /distributed.id
net.jrouter.id.local-file=localhost
# default: distributed.id
net.jrouter.id.redis-hash-key=distributed.id
# default: distributed.id
net.jrouter.id.zk-path=distributed.id
#default: redis, optional: (redis/zookeeper/local/manual)
net.jrouter.id.generator-type=redis
#default: 0, effective when "generatorType=manual"
net.jrouter.id.manual-worker-id=100