diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java index d80cbafb..f11c0860 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalController.java @@ -31,6 +31,7 @@ import ${domain}.frame.utils.LogUtil; import ${domain}.frame.utils.MD5Util; import ${domain}.frame.utils.MapperUtil; import ${domain}.frame.utils.StringUtil; +import ${domain}.module.wsys.mgr.LogerrManager; <#if project.frameValue() = 1> import ${domain}.module.wsys.mgr.TokensManager; import ${domain}.module.wsys.req.TokensBuildRequest; @@ -363,6 +364,12 @@ public class GlobalController { e.printStackTrace(); response.addError(ErrorType.BUSINESS_ERROR, "方法执必须公开!"); } catch (InvocationTargetException e) { + try { + LogerrManager logerrManager = LocalData.getBean(LogerrManager.class); + logerrManager.addErr("系统错误", e.getTargetException().getMessage(), LogUtil.getTrace(e)); + } catch (Exception ignored) { + + } LogUtil.dumpException(e.getTargetException()); e.getTargetException().printStackTrace(); response.addError(ErrorType.BUSINESS_ERROR, "方法执行错误[" + e.getTargetException().getMessage() + "]"); diff --git a/src/main/resources/modules/SpringBoot/java/action/GlobalErrorController.java b/src/main/resources/modules/SpringBoot/java/action/GlobalErrorController.java index 272d6ad5..0d15b6a1 100644 --- a/src/main/resources/modules/SpringBoot/java/action/GlobalErrorController.java +++ b/src/main/resources/modules/SpringBoot/java/action/GlobalErrorController.java @@ -69,8 +69,9 @@ public class GlobalErrorController extends BasicErrorController { modelAndView.setViewName("500"); } catch (Exception ignored) { + } finally { + modelAndView.setViewName("500"); } - modelAndView.setViewName("500"); break; } diff --git a/src/main/resources/modules/SpringBoot/java/frame/utils/LogUtil.java b/src/main/resources/modules/SpringBoot/java/frame/utils/LogUtil.java index 3a6d725f..4946d2d9 100644 --- a/src/main/resources/modules/SpringBoot/java/frame/utils/LogUtil.java +++ b/src/main/resources/modules/SpringBoot/java/frame/utils/LogUtil.java @@ -51,6 +51,13 @@ public class LogUtil { * 获取异常详细堆栈信息 */ public static void dumpException(Throwable e){ + logger.error(getTrace(e)); + } + + /** + * 获取异常详细堆栈信息 + */ + public static String getTrace(Throwable e){ StringBuffer msg = new StringBuffer("null"); if (e != null) { msg = new StringBuffer(""); @@ -65,6 +72,6 @@ public class LogUtil { msg.append(message); } } - logger.error(msg.toString()); + return msg.toString(); } }