[quote=引用 6 楼 fengspg 的回复:] [quote=引用 4 楼 MamyA 的回复:] [quote=引用 3 楼 fengspg 的回复:] AtomicLong at = new AtomicLong(); for (int i = 0; i < 10; i++) { Long atLong = at.incrementAndGet(); System.out.println(String.format("%09d", atLong)); }
AtomicLong at = new AtomicLong(); for (int i = 0; i < 10; i++) { Long atLong = at.incrementAndGet(); System.out.println(String.format("%09d", atLong)); }
[quote=引用 4 楼 MamyA 的回复:] [quote=引用 3 楼 fengspg 的回复:] AtomicLong at = new AtomicLong(); for (int i = 0; i < 10; i++) { Long atLong = at.incrementAndGet(); System.out.println(String.format("%09d", atLong)); }
不要想着坐享其成,你说的这个很好做,1、建议创建一个流水号表,写个方法从该表获取最新的流水号,然后按照规则自动增长(规则由你定),生成之后在存进数据库,每次都不相等。2、直接在你的业务表里获取流水号,然后自动增长。代码自己写
[quote=引用 3 楼 fengspg 的回复:] AtomicLong at = new AtomicLong(); for (int i = 0; i < 10; i++) { Long atLong = at.incrementAndGet(); System.out.println(String.format("%09d", atLong)); }
67,549
社区成员
225,860
社区内容
加载中
试试用AI创作助手写篇文章吧