提交 aae0f9a9 编写于 作者: T Thinkingcao

启动项目打印

上级 4774ce57
package com.silence;
import com.silence.common.config.Global;
import com.silence.common.utils.IpUtils;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;
/**
* 启动程序
......@@ -16,20 +19,34 @@ public class SilenceApplication
public static void main(String[] args)
{
System.setProperty("spring.devtools.restart.enabled", "false");
SpringApplication.run(SilenceApplication.class, args);
printKeyLoadMessage();
ConfigurableApplicationContext context = SpringApplication.run(SilenceApplication.class, args);
printKeyLoadMessage(context);
}
/**
* 获取Key加载信息
*/
public static boolean printKeyLoadMessage() {
public static boolean printKeyLoadMessage(ConfigurableApplicationContext context) {
ConfigurableEnvironment environment = context.getEnvironment();
// 项目端口
String port = environment.getProperty("server.port");
// 项目路径
String contextPath = environment.getProperty("server.servlet.context-path");
// 项目名称
// String projectFinalName = environment.getProperty("server.servlet.context-path");
String homeUrl = "http://" + IpUtils.getHostIp() + ":" + port + contextPath;
String swaggerUrl = "http://" + IpUtils.getHostIp() + ":" + port + contextPath+"/swagger-ui.html";
//http://127.0.0.1:8888/silence/swagger-ui.html
StringBuilder sb = new StringBuilder();
sb.append("\r\n======================================================================\r\n");
sb.append("\r\n (♥◠‿◠)ノ゙ Silence启动成功 ლ(´ڡ`ლ)゙ \r\n");
sb.append("\r\n 欢迎使用 " + Global.getName() + " - Silence-Boot.Version : 3.4.RELEASE\r\n");
sb.append("\r\n======================================================================\r\n");
System.out.println(sb.toString());
System.out.println("\thomeUrl: " + homeUrl);
System.out.println("\tswaggerUrl: " + swaggerUrl);
System.out.println("\r");
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册