Browse Source

修复空值错误

Menethil 7 years ago
parent
commit
c1e96bfef4

+ 8 - 6
litemall-wx-api/src/main/java/org/linlinjava/litemall/wx/service/SystemInistService.java

@@ -1,26 +1,28 @@
-package org.linlinjava.litemall.wx.service;
+package org.linlinjava.litemall.core.system;
 
-import org.linlinjava.litemall.core.system.SystemInfoPrinter;
+import org.linlinjava.litemall.core.util.SystemInfoPrinter;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.core.env.Environment;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
-import java.util.HashMap;
 import java.util.LinkedHashMap;
 import java.util.Map;
 
+/**
+ * 系统启动服务,用于检查系统状态及打印系统信息
+ */
 @Component
-public class SystemInistService {
+class SystemInistService {
     private SystemInistService systemInistService;
     @Autowired
     private Environment environment;
 
     @PostConstruct
-    public void inist() {
+    private void inist() {
         systemInistService = this;
 
-        SystemInfoPrinter.printInfo("WX-API 初始化信息", getSystemInfo());
+        SystemInfoPrinter.printInfo("Litemall 初始化信息", getSystemInfo());
     }
 
     private Map<String, String> getSystemInfo() {

+ 7 - 1
litemall-core/src/main/java/org/linlinjava/litemall/core/system/SystemInfoPrinter.java

@@ -1,4 +1,4 @@
-package org.linlinjava.litemall.core.system;
+package org.linlinjava.litemall.core.util;
 
 import java.util.Map;
 
@@ -21,6 +21,9 @@ public class SystemInfoPrinter {
 
     private static void setMaxSize(Map<String, String> infos) {
         for (Map.Entry<String, String> entry : infos.entrySet()) {
+            if (entry.getValue() == null)
+                continue;
+
             int size = entry.getKey().length() + entry.getValue().length();
 
             if (size > maxSize)
@@ -52,6 +55,9 @@ public class SystemInfoPrinter {
     }
 
     private static void printLine(String head, String line) {
+        if (line == null)
+            return;
+
         if (head.startsWith(CREATE_PART_COPPER)) {
             System.out.println("");
             System.out.println("    [[  " + line + "  ]]");