From 589f03a1039a0f07756ec8f9dbd577f061ad452d Mon Sep 17 00:00:00 2001 From: wangliwen Date: Thu, 14 Jul 2022 09:35:59 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BD=BF=E7=94=A8=E5=8D=95=E4=BE=8B=E6=9E=9A?= =?UTF-8?q?=E4=B8=BE=E4=BF=9D=E8=AF=81=E6=B5=81=E6=B0=B4=E5=8F=B7=E5=B7=A5?= =?UTF-8?q?=E5=85=B7=E7=B1=BB=E4=B8=BA=E5=85=A8=E5=B1=80=E5=8D=95=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../common/utils/CodeGenerationUtils.java | 21 ++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java b/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java index d6a8c9a4..aaaa9137 100644 --- a/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java +++ b/renren-admin/src/main/java/io/renren/common/utils/CodeGenerationUtils.java @@ -25,6 +25,23 @@ public class CodeGenerationUtils { } + /** + * 使用单例枚举保证全局单例 + */ + enum CodeGenerationUtilsEnum { + INSTANCE; + private CodeGenerationUtils codeGenerationUtils; + + CodeGenerationUtilsEnum() { + codeGenerationUtils = new CodeGenerationUtils(); + } + + public CodeGenerationUtils getInstnce() { + return codeGenerationUtils; + } + } + + /** * 生成流程单号 *

@@ -89,9 +106,7 @@ public class CodeGenerationUtils { } - private static CodeGenerationUtils codeGenerationUtils = new CodeGenerationUtils(); - public static CodeGenerationUtils getInstance() { - return codeGenerationUtils; + return CodeGenerationUtilsEnum.INSTANCE.getInstnce(); } }