Эх сурвалжийг харах

Merge branch 'dev_240725_mybatis_profiler' into release_1.0.5

luoshi 11 сар өмнө
parent
commit
0a02ec375c

+ 10 - 5
data-mybatis-plus/src/main/java/com/qmth/boot/mybatis/plugin/MybatisProfilerPlugin.java

@@ -45,8 +45,12 @@ public class MybatisProfilerPlugin implements Interceptor {
         Object result = invocation.proceed();
         long cost = System.currentTimeMillis() - start;
         if (profilerProperties.isEnable() && cost > profilerProperties.getThreshold().toMillis()) {
-            String sql = generateSql(invocation);
-            log.info("Sql time cost: " + cost + "ms\n" + sql);
+            try {
+                String sql = generateSql(invocation);
+                log.info("Sql time cost: " + cost + "ms\n" + sql);
+            } catch (Exception e) {
+                log.error("Sql profiler error", e);
+            }
         }
         return result;
     }
@@ -91,10 +95,11 @@ public class MybatisProfilerPlugin implements Interceptor {
                     } else if (boundSql.hasAdditionalParameter(propertyName)) {
                         Object obj = boundSql.getAdditionalParameter(propertyName);
                         sql = sql.replaceFirst("\\?", Matcher.quoteReplacement(getParameterValue(obj)));
-                    } else {
-                        // 如果都没有,说明SQL匹配不上,带上“缺失”方便找问题
-                        sql = sql.replaceFirst("\\?", "缺失");
                     }
+                    //else {
+                    // 如果都没有,说明SQL匹配不上,带上“缺失”方便找问题
+                    // sql = sql.replaceFirst("\\?", "缺失");
+                    //}
                 }
             }
         }