Explorar el Código

fix:issues/414 设置contextPath后演示地址未及时更新 (#415)

fuzi hace 2 años
padre
commit
281a9cfbab
Se han modificado 1 ficheros con 7 adiciones y 2 borrados
  1. 7 2
      server/src/main/java/cn/keking/ServerMain.java

+ 7 - 2
server/src/main/java/cn/keking/ServerMain.java

@@ -1,5 +1,6 @@
 package cn.keking;
 
+import org.apache.commons.lang3.StringUtils;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.springframework.boot.autoconfigure.SpringBootApplication;
@@ -24,8 +25,12 @@ public class ServerMain {
                 .logStartupInfo(false)
                 .run(args);
         stopWatch.stop();
-        Integer port = context.getBean(ServerProperties.class).getPort();
-        logger.info("kkFileView 服务启动完成,耗时:{}s,演示页请访问: http://127.0.0.1:{} ", stopWatch.getTotalTimeSeconds(), port);
+        ServerProperties serverProperties = context.getBean(ServerProperties.class);
+        Integer port = serverProperties.getPort();
+        ServerProperties.Servlet servlet = serverProperties.getServlet();
+        String contextPath = servlet.getContextPath();
+        String urlSuffix = StringUtils.isBlank(contextPath)? String.valueOf(port):port+contextPath;
+        logger.info("kkFileView 服务启动完成,耗时:{}s,演示页请访问: http://127.0.0.1:{} ", stopWatch.getTotalTimeSeconds(), urlSuffix);
     }
 
 }