🔨 规范化配置.
This commit is contained in:
@@ -36,24 +36,47 @@ public class BannerApplicationRunner implements ApplicationRunner {
|
||||
@Value("${management.endpoints.web.base-path:''}")
|
||||
private String managementEndpoints;
|
||||
|
||||
@Value("${springdoc.api-docs.enabled}")
|
||||
private Boolean apiDocsEnabled;
|
||||
|
||||
@Value("${spring.datasource.druid.stat-view-servlet.enabled}")
|
||||
private Boolean druidConsoleEnabled;
|
||||
|
||||
@Value("#{'${management.endpoints.web.exposure.include}' != 'shutdown'}")
|
||||
private Boolean springBootActuatorEnabled;
|
||||
|
||||
@Value("${spring.boot.admin.client.enabled}")
|
||||
private Boolean springBootAdminClientEnabled;
|
||||
|
||||
@Override
|
||||
public void run(ApplicationArguments args) {
|
||||
String line = AnsiAppender.create()
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor-launch v" + version + " 服务已启动(" + env + ") ::\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/doc.html\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: druid console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/druid/index.html\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: actuator endpoint ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + managementEndpoints + "\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: admin console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + adminSeverContextPath + "\n")
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: server 健康检测 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"")
|
||||
.toString();
|
||||
AnsiAppender appender = AnsiAppender.create()
|
||||
.append(AnsiForeground.BRIGHT_GREEN, ":: orion-visor-launch v" + version + " 服务已启动(" + env + ") ::\n");
|
||||
// swagger 地址
|
||||
if (apiDocsEnabled) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: swagger 文档 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/doc.html\n");
|
||||
}
|
||||
// druid 控制台
|
||||
if (druidConsoleEnabled) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: druid console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + "/druid/index.html\n");
|
||||
}
|
||||
// admin actuator 端点
|
||||
if (springBootActuatorEnabled) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: actuator endpoint ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + managementEndpoints + "\n");
|
||||
}
|
||||
// admin server 控制台
|
||||
if (springBootAdminClientEnabled) {
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: admin console ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "http://127.0.0.1:" + port + adminSeverContextPath + "\n");
|
||||
}
|
||||
appender.append(AnsiForeground.BRIGHT_GREEN, ":: server 健康检测 ")
|
||||
.append(AnsiForeground.BRIGHT_BLUE, "curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"");
|
||||
Threads.start(() -> {
|
||||
Threads.sleep(1000L);
|
||||
System.out.println(line);
|
||||
System.out.println(appender);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -8,4 +8,5 @@ ${AnsiColor.BRIGHT_GREEN}:: Application Name ${AnsiColor.BLUE}${spring.appli
|
||||
${AnsiColor.BRIGHT_GREEN}:: Application Version ${AnsiColor.BLUE}${orion.version}
|
||||
${AnsiColor.BRIGHT_GREEN}:: SpringBoot Version ${AnsiColor.BLUE}${spring-boot.version}
|
||||
${AnsiColor.BRIGHT_GREEN}:: Active Profile ${AnsiColor.BLUE}${spring.profiles.active}
|
||||
${AnsiColor.BRIGHT_GREEN}:: Demo Mode ${AnsiColor.BLUE}${orion.demo}
|
||||
${AnsiColor.DEFAULT}
|
||||
@@ -23,7 +23,6 @@ import org.springframework.boot.autoconfigure.condition.ConditionalOnClass;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
|
||||
import org.springframework.boot.context.properties.EnableConfigurationProperties;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.Profile;
|
||||
import org.springframework.http.HttpHeaders;
|
||||
|
||||
import java.util.HashMap;
|
||||
@@ -38,10 +37,9 @@ import java.util.Optional;
|
||||
* @version 1.0.0
|
||||
* @since 2022/6/21 11:22
|
||||
*/
|
||||
@Profile({"dev"})
|
||||
@ConditionalOnClass({OpenAPI.class})
|
||||
@EnableConfigurationProperties(SwaggerConfig.class)
|
||||
@ConditionalOnProperty(prefix = "springdoc.api-docs", name = "enabled", havingValue = "true", matchIfMissing = true)
|
||||
@ConditionalOnProperty(name = "springdoc.api-docs.enabled", havingValue = "true")
|
||||
@AutoConfiguration
|
||||
@AutoConfigureOrder(AutoConfigureOrderConst.FRAMEWORK_SWAGGER)
|
||||
public class OrionSwaggerAutoConfiguration {
|
||||
|
||||
Reference in New Issue
Block a user