Quellcode durchsuchen

修改配置平台地址输出缺少context-path和版本号问题

wangshuai vor 4 Jahren
Ursprung
Commit
44617a36e7

+ 17 - 10
magic-api-spring-boot-starter/src/main/java/org/ssssssss/magicapi/spring/boot/starter/ApplicationUriPrinter.java

@@ -1,5 +1,6 @@
 package org.ssssssss.magicapi.spring.boot.starter;
 
+import org.apache.commons.lang3.StringUtils;
 import org.springframework.boot.CommandLineRunner;
 import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
 import org.springframework.core.annotation.Order;
@@ -13,11 +14,11 @@ import java.net.UnknownHostException;
 /**
  * 输出服务访问地址
  * @author 冰点
- * @date 2020-6-17 11:44:04
- * @since 1.1.1
+ * @date 2021-6-3 12:08:59
+ * @since 1.2.1
  */
 @Component
-@ConditionalOnProperty(name = "spring.ex.config.access.url.show", havingValue = "true", matchIfMissing = true)
+@ConditionalOnProperty(name = "magic-api.show-url", havingValue = "true", matchIfMissing = true)
 @Order
 public class ApplicationUriPrinter implements CommandLineRunner {
     @Resource
@@ -34,17 +35,23 @@ public class ApplicationUriPrinter implements CommandLineRunner {
         }
         String port = springEnv.getProperty("server.port","port");
         String path =springEnv.getProperty("server.servlet.context-path","");
-        String magicWebPath =springEnv.getProperty("magic-api.web","/magic/web");
-        if(!magicWebPath.startsWith("/")){
-            magicWebPath="/"+magicWebPath;
-        }
+        String magicWebPath =springEnv.getProperty("magic-api.web","");
+
+
         System.out.println(
                 "服务启动成功,magic-api已内置启动! Access URLs:\n\t" +
                         "接口本地地址: \t\thttp://localhost:" + port + path + "/\n\t" +
-                        "接口外部访问地址: \thttp://" + ip + ":" + port + path + "/\n\t" +
-                        "接口配置平台: \thttp://" + ip + ":" + port +path+ magicWebPath + "/index.html\n"
+                        "接口外部访问地址: \thttp://" + ip + ":" + port + path + "/"
         );
-        System.out.println("****************************************************当前服务相关地址end 可通过配置关闭输出spring.ex.config.access.url.show=false****************************************************");
+        if(!StringUtils.isEmpty(magicWebPath)){
+            if(!magicWebPath.startsWith("/")){
+                magicWebPath="/"+magicWebPath;
+            }
+            System.out.println("\t接口配置平台: \t\thttp://" + ip + ":" + port +path+ magicWebPath + "/index.html\n"
+            );
+        }
+
+        System.out.println("****************************************************当前服务相关地址end 可通过配置关闭输出magic-api.show-url=false****************************************************");
 
     }
 }