mirror of
https://gitee.com/ssssssss-team/magic-api.git
synced 2026-06-09 18:32:16 +08:00
!23 更加精准的端口读取和添加 magic-api showUrl 配置提示。
Merge pull request !23 from 如梦技术/dev
This commit is contained in:
@@ -4,6 +4,7 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.boot.CommandLineRunner;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.web.context.WebServerApplicationContext;
|
||||
import org.springframework.core.annotation.Order;
|
||||
import org.springframework.core.env.ConfigurableEnvironment;
|
||||
import org.springframework.stereotype.Component;
|
||||
@@ -29,6 +30,8 @@ public class ApplicationUriPrinter implements CommandLineRunner {
|
||||
private ConfigurableEnvironment springEnv;
|
||||
@Autowired
|
||||
private MagicAPIProperties properties;
|
||||
@Autowired
|
||||
private WebServerApplicationContext serverApplicationContext;
|
||||
|
||||
@Override
|
||||
public void run(String... args) throws Exception {
|
||||
@@ -39,7 +42,7 @@ public class ApplicationUriPrinter implements CommandLineRunner {
|
||||
} catch (UnknownHostException e) {
|
||||
System.out.println("当前服务地址获取失败");
|
||||
}
|
||||
String port = springEnv.getProperty("server.port", "port");
|
||||
int port = serverApplicationContext.getWebServer().getPort();
|
||||
String path = springEnv.getProperty("server.servlet.context-path", "");
|
||||
String magicWebPath = properties.getWeb();
|
||||
String schema = "http://";
|
||||
|
||||
@@ -97,6 +97,10 @@ public class MagicAPIProperties {
|
||||
*/
|
||||
private String pushPath = "/_magic-api-sync";
|
||||
|
||||
/**
|
||||
* 启动完成之后打印地址
|
||||
*/
|
||||
private boolean showUrl = true;
|
||||
|
||||
@NestedConfigurationProperty
|
||||
private SecurityConfig securityConfig = new SecurityConfig();
|
||||
@@ -325,4 +329,13 @@ public class MagicAPIProperties {
|
||||
public void setPushPath(String pushPath) {
|
||||
this.pushPath = pushPath;
|
||||
}
|
||||
|
||||
public boolean isShowUrl() {
|
||||
return showUrl;
|
||||
}
|
||||
|
||||
public MagicAPIProperties setShowUrl(boolean showUrl) {
|
||||
this.showUrl = showUrl;
|
||||
return this;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user