# uid **Repository Path**: javen205/uid ## Basic Information - **Project Name**: uid - **Description**: 分布式唯一ID - **Primary Language**: Java - **License**: Apache-2.0 - **Default Branch**: master - **Homepage**: https://gitee.com/javen205/uid - **GVP Project**: No ## Statistics - **Stars**: 3 - **Forks**: 1 - **Created**: 2022-11-13 - **Last Updated**: 2025-04-27 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### SpringBoot ID 生成器 - [UUID](/doc/UUID.md) - [数据库自增ID](/doc/DB.md) - [号段模式](/doc/DB.md) - [Redis](/doc/Redis.md) - [雪花算法(SnowFlake)](/doc/SnowFlake.md) - [滴滴出品(TinyID)](https://github.com/didi/tinyid/wiki) - [百度分布式(UidGenerator)](https://github.com/baidu/uid-generator) - [美团(Leaf)](https://github.com/Meituan-Dianping/Leaf/blob/master/README_CN.md) - [多语言新雪花算法(SnowFlake IdGenerator)](https://gitee.com/yitter/idgenerator) ### 使用方法 #### 1. 添加依赖 ```xml com.github.javen205 uid-generator-spring-boot-starters ${latest-version} ``` #### 2. 配置参数 详细配置请参考 `uid-springboot-demo` 中的示例 > warning 注意 - `百度分布式生成方案` 需要使用数据库存储,所以需要配置数据库连接信息,脚本在 `scripts` 中 - `多语言新雪花算法` 不需要数据库存储,所以不需要配置数据库连接信息 - `uuid 方案` 需要配置生成的长度以及随机类型 - `Leaf 方案` - 雪花算法需要使用 ZK - 号段模式需要使用数据库,脚本在 `scripts` 中 ```yaml server: port: 7030 javen: uid: count: 6 random-type: int leaf: uid: # 数据段号模式 segment-enable: true jdbc-url: ${spring.datasource.url} jdbc-username: ${spring.datasource.username} jdbc-password: ${spring.datasource.password} # 雪花算法模式 snowflake-enable: false zk-address: 127.0.0.1 port: 2181 # DataSource Config spring: datasource: username: root password: root driver-class-name: com.mysql.cj.jdbc.Driver url: jdbc:mysql://127.0.0.1:3306/ui?useUnicode=true&characterEncoding=utf8&autoReconnect=true&zeroDateTimeBehavior=convertToNull&transformedBitIsBoolean=true&useSSL=false&allowMultiQueries=true mybatis-plus: mapper-locations: classpath*:mapper/**/*Mapper.xml,classpath*:/mapper/WORKER_NODE.xml # Logger Config logging: level: com.javen: debug ```