🔨 规范化配置.
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 {
|
||||
|
||||
@@ -7,6 +7,8 @@ spring:
|
||||
initial-size: 0
|
||||
min-idle: 1
|
||||
max-active: 5
|
||||
stat-view-servlet:
|
||||
enabled: false
|
||||
redis:
|
||||
host: 127.0.0.1
|
||||
port: 6379
|
||||
@@ -15,6 +17,19 @@ spring:
|
||||
threads: 2
|
||||
netty-threads: 2
|
||||
minimum-idle-size: 2
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
enabled: false
|
||||
server:
|
||||
enabled: false
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
enabled-by-default: false
|
||||
web:
|
||||
exposure:
|
||||
include: shutdown
|
||||
|
||||
mybatis-plus:
|
||||
configuration:
|
||||
|
||||
@@ -10,10 +10,13 @@ spring:
|
||||
min-idle: 5
|
||||
# 最大连接池数量
|
||||
max-active: 20
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
# 控制台
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
login-username: ${DRUID_USERNAME:admin}
|
||||
login-password: ${DRUID_PASSWORD:admin}
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
@@ -31,6 +34,16 @@ spring:
|
||||
quartz:
|
||||
threadPool:
|
||||
threadCount: 10
|
||||
boot:
|
||||
admin:
|
||||
client:
|
||||
enabled: true
|
||||
server:
|
||||
enabled: true
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
enabled-by-default: true
|
||||
|
||||
springdoc:
|
||||
api-docs:
|
||||
@@ -40,6 +53,7 @@ springdoc:
|
||||
|
||||
knife4j:
|
||||
enable: false
|
||||
production: true
|
||||
|
||||
orion:
|
||||
# 是否为演示模式
|
||||
|
||||
@@ -40,13 +40,14 @@ spring:
|
||||
# 最大生存的时间
|
||||
max-evictable-idle-time-millis: 900000
|
||||
validation-query: SELECT 1
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
# 控制台
|
||||
stat-view-servlet:
|
||||
enabled: true
|
||||
url-pattern: /druid/*
|
||||
login-username:
|
||||
login-password:
|
||||
web-stat-filter:
|
||||
enabled: true
|
||||
filter:
|
||||
stat:
|
||||
enabled: true
|
||||
@@ -88,7 +89,7 @@ spring:
|
||||
misfireThreshold: 60000
|
||||
clusterCheckinInterval: 5000
|
||||
isClustered: true
|
||||
#连接池
|
||||
# 连接池
|
||||
threadPool:
|
||||
class: org.quartz.simpl.SimpleThreadPool
|
||||
threadCount: 5
|
||||
@@ -98,12 +99,16 @@ spring:
|
||||
admin:
|
||||
context-path: /admin
|
||||
client:
|
||||
enabled: true
|
||||
url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path}
|
||||
instance:
|
||||
service-host-type: IP
|
||||
server:
|
||||
enabled: true
|
||||
|
||||
management:
|
||||
endpoints:
|
||||
enabled-by-default: true
|
||||
web:
|
||||
base-path: /actuator
|
||||
exposure:
|
||||
|
||||
Reference in New Issue
Block a user