Commit 269e0fc7 by hweeeeeei

修复:解决多线程并发下Snowflake生成重复id问题; 解决思路:将Snowflake()做成静态

parent d7e7c09a
...@@ -2,10 +2,17 @@ package io.geekidea.springbootplus.framework.shiro.util; ...@@ -2,10 +2,17 @@ package io.geekidea.springbootplus.framework.shiro.util;
import cn.hutool.core.lang.Snowflake; import cn.hutool.core.lang.Snowflake;
/**
* 雪花算法 获取id工具类
*
* @author
*/
public class SnowflakeUtil { public class SnowflakeUtil {
private static final Snowflake SNOWFLAKE = new Snowflake(1L, 1L);
public static Long getId() { public static Long getId() {
return new Snowflake(1L, 1L).nextId(); return SNOWFLAKE.nextId();
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment