This commit is contained in:
linfso 2025-02-22 16:44:59 +08:00
parent d662666e66
commit a3c05dbb77

View File

@ -47,7 +47,6 @@ public class LaunchApplication extends SpringBootServletInitializer {
System.out.println("use config file:" + configFile); System.out.println("use config file:" + configFile);
} catch (Exception e) { } catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace(); e.printStackTrace();
} }
ConfigurableApplicationContext context = ConfigurableApplicationContext context =
@ -56,14 +55,9 @@ public class LaunchApplication extends SpringBootServletInitializer {
.properties("spring.config.location=" + configFile) .properties("spring.config.location=" + configFile)
.web(WebApplicationType.SERVLET).run(args); .web(WebApplicationType.SERVLET).run(args);
// 获取Environment实例
Environment env = context.getEnvironment(); Environment env = context.getEnvironment();
// 获取端口号和上下文路径
String serverPort = env.getProperty("server.port"); String serverPort = env.getProperty("server.port");
String contextPath = env.getProperty("server.servlet.context-path", ""); String contextPath = env.getProperty("server.servlet.context-path", "");
// 打印启动信息
System.out.println("\n\n==>系统启动成功!server.port=" + serverPort + " context-path=" + contextPath); System.out.println("\n\n==>系统启动成功!server.port=" + serverPort + " context-path=" + contextPath);
} }