Skip to content

yookue/snowflake-uid-spring-boot-starter

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Snowflake UID Spring Boot Starter

Spring Boot application integrates snowflake quickly, to generate unique identifiers in order.

Quickstart

  • Import dependencies
    <dependency>
        <groupId>com.yookue.springstarter</groupId>
        <artifactId>snowflake-uid-spring-boot-starter</artifactId>
        <version>LATEST</version>
    </dependency>

By default, this starter will auto take effect, you can turn it off by spring.snowflake-uid.enabled = false

  • Configure Spring Boot application.yml with prefix spring.snowflake-uid (Optional)
spring:
    snowflake-uid:
        epochPoint: '2022-01-01'
  • Configure your beans with a UidGenerator bean by constructor or @Autowired/@Resource annotation, then you can access it as you wish.

    There are two different implements of UidGenerator for different scenarios:

Implement Class Primary Bean
DefaultUidGenerator Yes
CacheableUidGenerator No

Document

Requirement

  • jdk 17+

License

This project is under the Apache License 2.0

See the NOTICE.txt file for required notices and attributions.

Donation

You like this package? Then donate to Yookue to support the development.

Website