<hutool.version>5.4.7</hutool.version>
<dependency>
<groupId>cn.hutool</groupId>
<artifactId>hutool-all</artifactId>
<version>${hutool.version}</version>
</dependency>
@Configuration
public class SnowflakeGeneratorConfig {
@Bean
public SnowflakeGenerator snowflakeGenerator() {
return new SnowflakeGenerator();
}
}
<!-- 相当于基于注解的启动类 AnnotationConfigApplicationContext-->
<context:annotation-config />
<bean class="com.weihui.enterprise.domainservice.main.service.snowflake.SnowflakeGeneratorConfig"/>
使用
@Autowired
private SnowflakeGenerator snowflakeGenerator;
String s = snowflakeGenerator.next().toString();
java雪花算法
最新推荐文章于 2024-07-17 11:02:53 发布