diff --git a/src/main/java/io/jboot/apidoc/ApiJsonGenerator.java b/src/main/java/io/jboot/apidoc/ApiJsonGenerator.java index a2ba83ae7f352a29964e740ffc8a729da1a8282f..60a087f89be4635dcf40beb0247dc55c981eed19 100644 --- a/src/main/java/io/jboot/apidoc/ApiJsonGenerator.java +++ b/src/main/java/io/jboot/apidoc/ApiJsonGenerator.java @@ -15,6 +15,8 @@ */ package io.jboot.apidoc; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.parser.Feature; import com.jfinal.kit.PathKit; @@ -101,8 +103,9 @@ public class ApiJsonGenerator { String jsonContent = JSONObject.toJSONString(root, true); FileUtil.writeString(file, jsonContent); - - System.out.println("Gen Remarks Json File ----->" + FileUtil.getCanonicalPath(file)); + if (isPrintScannerInfoEnable()) { + System.out.println("Gen Remarks Json File ----->" + FileUtil.getCanonicalPath(file)); + } } @@ -211,8 +214,9 @@ public class ApiJsonGenerator { String jsonContent = JSONObject.toJSONString(root, true); FileUtil.writeString(file, jsonContent); - - System.out.println("Gen Remarks Json File ----->" + FileUtil.getCanonicalPath(file)); + if (isPrintScannerInfoEnable()) { + System.out.println("Gen Remarks Json File ----->" + FileUtil.getCanonicalPath(file)); + } } diff --git a/src/main/java/io/jboot/app/ApplicationUtil.java b/src/main/java/io/jboot/app/ApplicationUtil.java index f4c1d5a63fe54a514b04d02ee6abfdcd72c46350..139e59d2b47ba3e27d20e63f04311c6e79de190e 100644 --- a/src/main/java/io/jboot/app/ApplicationUtil.java +++ b/src/main/java/io/jboot/app/ApplicationUtil.java @@ -15,6 +15,8 @@ */ package io.jboot.app; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import io.jboot.app.config.JbootConfigManager; import java.io.File; @@ -39,7 +41,9 @@ public class ApplicationUtil { } static void printApplicationInfo(JbootApplicationConfig appConfig) { - System.out.println(appConfig.toString()); + if (isPrintScannerInfoEnable()) { + System.out.println(appConfig.toString()); + } } private static Boolean runInFatjar; @@ -86,14 +90,18 @@ public class ApplicationUtil { static void printClassPath() { try { if (runInFatjar()) { - System.out.println("JbootApplication is running in fatjar."); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication is running in fatjar."); + } } else { String path = ApplicationUtil.class.getResource("/").getPath(); // 例如: /D:/JAVA/workSpace_idea/... if (path.indexOf(":") == 2) { path = path.substring(1); } - System.out.println("JbootApplication classpath: " + path); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication classpath: " + path); + } } } catch (Exception e) { e.printStackTrace(); diff --git a/src/main/java/io/jboot/app/JbootResourceLoader.java b/src/main/java/io/jboot/app/JbootResourceLoader.java index cf415699e4343da56e5b42a0ce467e5ec2b92fbc..a4c71e8e9a9c41eebd3c36d2484f0a7d34b5a760 100644 --- a/src/main/java/io/jboot/app/JbootResourceLoader.java +++ b/src/main/java/io/jboot/app/JbootResourceLoader.java @@ -15,6 +15,8 @@ */ package io.jboot.app; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import io.jboot.app.config.JbootConfigManager; import io.jboot.utils.FileScanner; import io.jboot.utils.StrUtil; @@ -76,7 +78,9 @@ public class JbootResourceLoader { public void stop() { scanners.forEach(FileScanner::stop); - System.out.println("JbootResourceLoader has stopped."); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootResourceLoader has stopped."); + } } private void findResourcesPath(File root, List resourcesDirs) { diff --git a/src/main/java/io/jboot/app/JbootSimpleApplication.java b/src/main/java/io/jboot/app/JbootSimpleApplication.java index f5bacdd8adfbd9777305da6641f007b4fac5e859..a9c485071148a89719d06266604f3696ef03e4a9 100644 --- a/src/main/java/io/jboot/app/JbootSimpleApplication.java +++ b/src/main/java/io/jboot/app/JbootSimpleApplication.java @@ -15,6 +15,8 @@ */ package io.jboot.app; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.jfinal.config.Interceptors; import com.jfinal.config.Plugins; import com.jfinal.core.JFinal; @@ -129,7 +131,9 @@ public class JbootSimpleApplication { @Override public void run() { String seconds = new DecimalFormat("#.#").format((System.currentTimeMillis() - startTimeMillis) / 1000F); - System.out.println("JbootApplication has started in " + seconds + " seconds. Welcome To The Jboot World (^_^)\n\n"); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication has started in " + seconds + " seconds. Welcome To The Jboot World (^_^)\n\n"); + } initShutdownHook(); startAwait(); @@ -138,13 +142,19 @@ public class JbootSimpleApplication { private void initShutdownHook() { Runtime.getRuntime().addShutdownHook(new Thread(() -> { - System.out.println("\nJbootApplication shutdown, please wait ...... "); + if (isPrintScannerInfoEnable()) { + System.out.println("\nJbootApplication shutdown, please wait ...... "); + } try { coreConfig.onStop(); } catch (Exception e) { - System.out.println("JbootApplication shutdown exception: " + e.toString()); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication shutdown exception: " + e.toString()); + } + } + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication has exited, all services stopped."); } - System.out.println("JbootApplication has exited, all services stopped."); try { LOCK.lock(); STOP.signal(); @@ -160,7 +170,9 @@ public class JbootSimpleApplication { LOCK.lock(); STOP.await(); } catch (InterruptedException e) { - System.out.println("JbootApplication has stopped, interrupted by other thread!"); + if (isPrintScannerInfoEnable()) { + System.out.println("JbootApplication has stopped, interrupted by other thread!"); + } } finally { LOCK.unlock(); } diff --git a/src/main/java/io/jboot/codegen/CodeGenHelpler.java b/src/main/java/io/jboot/codegen/CodeGenHelpler.java index 16afe3fa7de221552fd776cc190a2150bea1ff69..4e6c2f4fe22a86566f70f789c67765de9f017754 100644 --- a/src/main/java/io/jboot/codegen/CodeGenHelpler.java +++ b/src/main/java/io/jboot/codegen/CodeGenHelpler.java @@ -103,7 +103,7 @@ public class CodeGenHelpler { metaBuilder.setDialect(new InformixDialect()); break; default: - throw new JbootIllegalConfigException("Only support datasource type: mysql、orcale、sqlserver、sqlite、ansisql、postgresql and infomix" + + throw new JbootIllegalConfigException("Only support datasource type: mysql、oracle、sqlserver、sqlite、ansisql、postgresql and infomix" + ", please check your jboot.properties. "); } diff --git a/src/main/java/io/jboot/components/gateway/GatewayInvocation.java b/src/main/java/io/jboot/components/gateway/GatewayInvocation.java index b87abd8330699574fa1f395910641fabf2b865d7..6a6c1dba98bccb4d83a4635f7cae1b674f0ad9d8 100644 --- a/src/main/java/io/jboot/components/gateway/GatewayInvocation.java +++ b/src/main/java/io/jboot/components/gateway/GatewayInvocation.java @@ -15,6 +15,8 @@ */ package io.jboot.components.gateway; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.jfinal.kit.Ret; import io.jboot.Jboot; import io.jboot.utils.StrUtil; @@ -72,7 +74,9 @@ public class GatewayInvocation { } if (devMode) { - System.out.println("Jboot Gateway >>> " + proxyUrl); + if (isPrintScannerInfoEnable()) { + System.out.println("Jboot Gateway >>> " + proxyUrl); + } } //启用 Sentinel 限流 diff --git a/src/main/java/io/jboot/db/ArpManager.java b/src/main/java/io/jboot/db/ArpManager.java index 4d445817fc2207bcdb396242b400945f3ba59e67..65051d04b6ab283c84fc81546bcc2122849eb3f0 100644 --- a/src/main/java/io/jboot/db/ArpManager.java +++ b/src/main/java/io/jboot/db/ArpManager.java @@ -257,7 +257,7 @@ public class ArpManager { activeRecordPlugin.setDialect(new JbootInformixDialect()); break; default: - throw new JbootIllegalConfigException("only support datasource type: mysql、orcale、sqlserver、sqlite、ansisql、postgresql and clickhouse, please check your jboot.properties. "); + throw new JbootIllegalConfigException("only support datasource type: mysql、oracle、sqlserver、sqlite、ansisql、postgresql and clickhouse, please check your jboot.properties. "); } } diff --git a/src/main/java/io/jboot/db/SqlDebugger.java b/src/main/java/io/jboot/db/SqlDebugger.java index cc5287ced9e11433deadd0c168ac82958959505d..2199be4baffba7cc766d0652de032c0b4c26aec6 100644 --- a/src/main/java/io/jboot/db/SqlDebugger.java +++ b/src/main/java/io/jboot/db/SqlDebugger.java @@ -15,6 +15,8 @@ */ package io.jboot.db; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.jfinal.log.Log; import com.jfinal.plugin.activerecord.Config; import io.jboot.Jboot; @@ -109,9 +111,13 @@ public class SqlDebugger { @Override public void print(String sql, Long tookTimeMillis) { if (tookTimeMillis != null) { - System.out.println("Jboot exec sql took " + tookTimeMillis + " ms >>> " + sql); + if (isPrintScannerInfoEnable()) { + System.out.println("Jboot exec sql took " + tookTimeMillis + " ms >>> " + sql); + } } else { - System.out.println("Jboot exec sql >>> " + sql); + if (isPrintScannerInfoEnable()) { + System.out.println("Jboot exec sql >>> " + sql); + } } } }; diff --git a/src/main/java/io/jboot/support/metric/reporter/prometheus/PrometheusReporter.java b/src/main/java/io/jboot/support/metric/reporter/prometheus/PrometheusReporter.java index 623b635397de16aa240deca052e4d7298d593a4b..ee82d44699ad480702fe188c2d009b9b6850930d 100644 --- a/src/main/java/io/jboot/support/metric/reporter/prometheus/PrometheusReporter.java +++ b/src/main/java/io/jboot/support/metric/reporter/prometheus/PrometheusReporter.java @@ -15,6 +15,8 @@ */ package io.jboot.support.metric.reporter.prometheus; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.codahale.metrics.MetricRegistry; import io.jboot.Jboot; import io.jboot.exception.JbootIllegalConfigException; @@ -37,7 +39,9 @@ public class PrometheusReporter implements JbootMetricReporter { try { httpServer = new HTTPServer(config.getHost(), config.getPort()); String printMsg = "Prometheus Reporter Server started -> http://" + config.getHost() + ":" + config.getPort(); - System.out.println(printMsg); + if (isPrintScannerInfoEnable()) { + System.out.println(printMsg); + } } catch (IOException e) { throw new JbootIllegalConfigException("Prometheus config is error, please check your jboot.properties. ", e); } diff --git a/src/main/java/io/jboot/test/MockMvcResult.java b/src/main/java/io/jboot/test/MockMvcResult.java index e7a1d51a98606bb5255108b8a24c4fc5dfae4628..d26635630ccb16b07ae802e56689d91939872c52 100644 --- a/src/main/java/io/jboot/test/MockMvcResult.java +++ b/src/main/java/io/jboot/test/MockMvcResult.java @@ -15,6 +15,8 @@ */ package io.jboot.test; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import io.jboot.test.web.MockHttpServletResponse; @@ -84,12 +86,16 @@ public class MockMvcResult { } public MockMvcResult printResult() { - System.out.println(this); + if (isPrintScannerInfoEnable()) { + System.out.println(this); + } return this; } public MockMvcResult printContent() { - System.out.println(getContent()); + if (isPrintScannerInfoEnable()) { + System.out.println(getContent()); + } return this; } diff --git a/src/main/java/io/jboot/test/web/MockServletContext.java b/src/main/java/io/jboot/test/web/MockServletContext.java index 32f624259a982e7c2462ed5a1db09f2636df1863..197b43c58de19981d5fa75aaccc25bae70e2d151 100644 --- a/src/main/java/io/jboot/test/web/MockServletContext.java +++ b/src/main/java/io/jboot/test/web/MockServletContext.java @@ -15,6 +15,8 @@ */ package io.jboot.test.web; +import static io.jboot.utils.ClassScanner.isPrintScannerInfoEnable; + import com.jfinal.kit.PathKit; import io.jboot.components.http.HttpMimeTypes; import io.jboot.test.MockExceptions; @@ -128,18 +130,24 @@ public class MockServletContext implements ServletContext { @Override public void log(String msg) { - System.out.println(msg); + if (isPrintScannerInfoEnable()) { + System.out.println(msg); + } } @Override public void log(Exception exception, String msg) { - System.out.println(msg); + if (isPrintScannerInfoEnable()) { + System.out.println(msg); + } exception.printStackTrace(); } @Override public void log(String message, Throwable throwable) { - System.out.println(message); + if (isPrintScannerInfoEnable()) { + System.out.println(message); + } throwable.printStackTrace(); }