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(); } }