id-spring-boot-starter

distribute id generator use snowflake algorithm.

License

License

Categories

Categories

Spring Boot Container Microservices
GroupId

GroupId

cn.ocoop.framework
ArtifactId

ArtifactId

id-spring-boot-starter
Last Version

Last Version

1.1.0
Release Date

Release Date

Type

Type

jar
Description

Description

id-spring-boot-starter
distribute id generator use snowflake algorithm.
Project URL

Project URL

https://github.com/xfeat/id-spring-boot-starter
Source Code Management

Source Code Management

https://github.com/xfeat/id-spring-boot-starter

Download id-spring-boot-starter

How to add to project

<!-- https://jarcasting.com/artifacts/cn.ocoop.framework/id-spring-boot-starter/ -->
<dependency>
    <groupId>cn.ocoop.framework</groupId>
    <artifactId>id-spring-boot-starter</artifactId>
    <version>1.1.0</version>
</dependency>
// https://jarcasting.com/artifacts/cn.ocoop.framework/id-spring-boot-starter/
implementation 'cn.ocoop.framework:id-spring-boot-starter:1.1.0'
// https://jarcasting.com/artifacts/cn.ocoop.framework/id-spring-boot-starter/
implementation ("cn.ocoop.framework:id-spring-boot-starter:1.1.0")
'cn.ocoop.framework:id-spring-boot-starter:jar:1.1.0'
<dependency org="cn.ocoop.framework" name="id-spring-boot-starter" rev="1.1.0">
  <artifact name="id-spring-boot-starter" type="jar" />
</dependency>
@Grapes(
@Grab(group='cn.ocoop.framework', module='id-spring-boot-starter', version='1.1.0')
)
libraryDependencies += "cn.ocoop.framework" % "id-spring-boot-starter" % "1.1.0"
[cn.ocoop.framework/id-spring-boot-starter "1.1.0"]

Dependencies

compile (8)

Group / Artifact Type Version
org.springframework.boot : spring-boot-autoconfigure jar
org.springframework.boot : spring-boot-configuration-processor Optional jar
org.projectlombok : lombok Optional jar
org.apache.commons : commons-lang3 jar
org.springframework.data : spring-data-redis Optional jar
com.google.guava : guava jar 25.1-jre
commons-io : commons-io jar 2.5
org.apache.commons : commons-collections4 jar 4.1

Project Modules

There are no modules declared in this project.

分布式id生成器

简介

这是一个spring-boot-starter,如果你还不了解spring-boot以及它的starter如何使用,请先学习spring-boot。

基于snowflake(雪花算法)id生成方案(需要spring-data-redis支持)

使用

  • step1:添加依赖
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-redis</artifactId>
    </dependency>
    
    <dependency>
        <groupId>cn.ocoop.framework</groupId>
        <artifactId>id-spring-boot-starter</artifactId>
        <version>1.1.0</version>
    </dependency>
  • step2:配置yml
spring:
  redis:
    url: redis://localhost:6379 #redis配置
id:
  key: 'worker_id_sequence'     #该id服务所属的集群key,将所有生成不重复id的key设置为相同               
  • step3:java
        long id = Id.next();        
cn.ocoop.framework

xfeat

Versions

Version
1.1.0
1.0.0