高并发id生产策略

 
 
<!-- 顺序UUID -->
<dependency>
<groupId>com.fasterxml.uuid</groupId>
<artifactId>java-uuid-generator</artifactId>
<version>3.1.4</version>
</dependency>

import
com.fasterxml.uuid.EthernetAddress; import com.fasterxml.uuid.Generators; import com.fasterxml.uuid.impl.TimeBasedGenerator; public class KeyUtil { public static String generatorUUID(){ TimeBasedGenerator timeBasedGenerator = Generators.timeBasedGenerator(EthernetAddress.fromInterface()); return timeBasedGenerator.generate().toString(); } public static void main(String[] args) { System.err.println(KeyUtil.generatorUUID()); System.err.println(KeyUtil.generatorUUID()); } }

 

 高并发下同意id生产

 

 

猜你喜欢

转载自www.cnblogs.com/xjatj/p/11372082.html