diff --git a/orion-ops-dependencies/pom.xml b/orion-ops-dependencies/pom.xml
index 79c03ce9..a0357a51 100644
--- a/orion-ops-dependencies/pom.xml
+++ b/orion-ops-dependencies/pom.xml
@@ -16,7 +16,7 @@
1.0.0
2.7.11
- 1.0.6
+ 1.0.6
1.9.7
1.18.26
1.6.15
@@ -27,6 +27,7 @@
2.3
1.2.16
3.18.0
+ 2.7.10
2.14.2
@@ -44,7 +45,7 @@
io.github.lijiahangmax
orion-all
- ${orion.all.version}
+ ${orion.kit.revision}
orion-log
@@ -119,6 +120,11 @@
orion-ops-spring-boot-starter-security
${revision}
+
+ com.orion.ops
+ orion-ops-spring-boot-starter-monitor
+ ${revision}
+
@@ -209,6 +215,25 @@
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+ ${spring.boot.version}
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+ ${spring-boot-admin.version}
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+ ${spring-boot-admin.version}
+
+
com.alibaba
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-banner/src/main/java/com/orion/ops/framework/banner/core/BannerApplicationRunner.java b/orion-ops-framework/orion-ops-spring-boot-starter-banner/src/main/java/com/orion/ops/framework/banner/core/BannerApplicationRunner.java
index 56e8df6f..d24c1264 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-banner/src/main/java/com/orion/ops/framework/banner/core/BannerApplicationRunner.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-banner/src/main/java/com/orion/ops/framework/banner/core/BannerApplicationRunner.java
@@ -1,5 +1,6 @@
package com.orion.ops.framework.banner.core;
+import com.orion.lang.utils.Threads;
import com.orion.lang.utils.ansi.AnsiColor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Value;
@@ -28,18 +29,31 @@ public class BannerApplicationRunner implements ApplicationRunner {
@Value("${orion.api.prefix}")
private String apiPrefix;
+ @Value("${spring.boot.admin.context-path:''}")
+ private String adminSeverContextPath;
+
+ @Value("${management.endpoints.web.base-path:''}")
+ private String managementEndpoints;
+
@Override
public void run(ApplicationArguments args) {
String line = AnsiColor.GLOSS_GREEN.color(":: orion-ops-launch v" + version + " 服务已启动(" + env + ") ::\n") +
- AnsiColor.GLOSS_GREEN.color(":: swagger 文档 ") +
+ AnsiColor.GLOSS_GREEN.color(":: swagger 文档 ") +
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + "/doc.html\n") +
- AnsiColor.GLOSS_GREEN.color(":: druid console ") +
+ AnsiColor.GLOSS_GREEN.color(":: druid console ") +
AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + "/druid/index.html\n") +
+ AnsiColor.GLOSS_GREEN.color(":: actuator endpoint ") +
+ AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + managementEndpoints + "\n") +
+ AnsiColor.GLOSS_GREEN.color(":: admin console ") +
+ AnsiColor.GLOSS_BLUE.color("http://127.0.0.1:" + port + adminSeverContextPath + "\n") +
AnsiColor.GLOSS_GREEN.color(":: server 健康检测 ") +
AnsiColor.GLOSS_BLUE +
"curl -X GET --location \"http://127.0.0.1:" + port + apiPrefix + "/server/bootstrap/health\"" +
AnsiColor.SUFFIX;
- System.out.println(line);
+ Threads.start(() -> {
+ Threads.sleep(1000L);
+ System.out.println(line);
+ });
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-monitor/pom.xml b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/pom.xml
new file mode 100644
index 00000000..1394ed4a
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/pom.xml
@@ -0,0 +1,42 @@
+
+
+
+ com.orion.ops
+ orion-ops-framework
+ ${revision}
+
+
+ 4.0.0
+ orion-ops-spring-boot-starter-monitor
+ ${project.artifactId}
+ jar
+
+ 项目监控配置包
+ https://github.com/lijiahangmax/orion-ops-pro
+
+
+
+ com.orion.ops
+ orion-ops-common
+
+
+
+
+ org.springframework.boot
+ spring-boot-starter-actuator
+
+
+
+
+ de.codecentric
+ spring-boot-admin-starter-server
+
+
+ de.codecentric
+ spring-boot-admin-starter-client
+
+
+
+
\ No newline at end of file
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/java/com/orion/ops/framework/monitor/config/OrionAdminAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/java/com/orion/ops/framework/monitor/config/OrionAdminAutoConfiguration.java
new file mode 100644
index 00000000..a531cf42
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/java/com/orion/ops/framework/monitor/config/OrionAdminAutoConfiguration.java
@@ -0,0 +1,39 @@
+package com.orion.ops.framework.monitor.config;
+
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import de.codecentric.boot.admin.server.config.EnableAdminServer;
+import de.codecentric.boot.admin.server.utils.jackson.AdminServerModule;
+import org.springframework.boot.autoconfigure.AutoConfiguration;
+import org.springframework.boot.autoconfigure.AutoConfigureAfter;
+import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
+import org.springframework.context.annotation.Bean;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
+
+/**
+ * 项目 admin console 配置
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2023/7/11 14:13
+ */
+@EnableAdminServer
+@AutoConfiguration
+@AutoConfigureAfter(name = "com.orion.ops.framework.web.config.OrionWebAutoConfiguration")
+public class OrionAdminAutoConfiguration {
+
+ /**
+ * @param converter jackson converter
+ * @return springboot-admin 序列化配置
+ */
+ @Bean
+ @ConditionalOnBean(MappingJackson2HttpMessageConverter.class)
+ public SimpleModule registrationModuleConverter(MappingJackson2HttpMessageConverter converter) {
+ ObjectMapper objectMapper = converter.getObjectMapper();
+ // 序列化配置
+ AdminServerModule module = new AdminServerModule(new String[]{".*password$"});
+ objectMapper.registerModule(module);
+ return module;
+ }
+
+}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
new file mode 100644
index 00000000..25250af2
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-monitor/src/main/resources/META-INF/spring/org.springframework.boot.autoconfigure.AutoConfiguration.imports
@@ -0,0 +1 @@
+com.orion.ops.framework.monitor.config.OrionAdminAutoConfiguration
\ No newline at end of file
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/config/OrionMybatisAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/config/OrionMybatisAutoConfiguration.java
index 08386492..825f6650 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/config/OrionMybatisAutoConfiguration.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/config/OrionMybatisAutoConfiguration.java
@@ -3,7 +3,7 @@ package com.orion.ops.framework.mybatis.config;
import com.baomidou.mybatisplus.core.handlers.MetaObjectHandler;
import com.orion.ops.framework.common.constant.FilterOrderConst;
import com.orion.ops.framework.common.filter.FilterCreator;
-import com.orion.ops.framework.mybatis.core.cache.RowCacheClearFilter;
+import com.orion.ops.framework.mybatis.core.cache.CacheClearFilter;
import com.orion.ops.framework.mybatis.core.handler.FieldFillHandler;
import org.apache.ibatis.annotations.Mapper;
import org.mybatis.spring.annotation.MapperScan;
@@ -35,8 +35,8 @@ public class OrionMybatisAutoConfiguration {
* @return mybatis 缓存清理过滤器
*/
@Bean
- public FilterRegistrationBean rowCacheClearFilterBean() {
- return FilterCreator.create(new RowCacheClearFilter(), FilterOrderConst.MYBATIS_CACHE_CLEAR_FILTER);
+ public FilterRegistrationBean rowCacheClearFilterBean() {
+ return FilterCreator.create(new CacheClearFilter(), FilterOrderConst.MYBATIS_CACHE_CLEAR_FILTER);
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheClearFilter.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheClearFilter.java
similarity index 88%
rename from orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheClearFilter.java
rename to orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheClearFilter.java
index ddfcb842..fdd01661 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheClearFilter.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheClearFilter.java
@@ -15,7 +15,7 @@ import java.io.IOException;
* @version 1.0.0
* @since 2023/6/25 15:14
*/
-public class RowCacheClearFilter extends OncePerRequestFilter {
+public class CacheClearFilter extends OncePerRequestFilter {
@Override
protected void doFilterInternal(HttpServletRequest request, HttpServletResponse response, FilterChain filterChain) throws ServletException, IOException {
@@ -25,7 +25,7 @@ public class RowCacheClearFilter extends OncePerRequestFilter {
} finally {
// 清理缓存
// TODO TEST
- RowCacheHolder.remove();
+ CacheHolder.remove();
}
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheHolder.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheHolder.java
similarity index 95%
rename from orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheHolder.java
rename to orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheHolder.java
index 6a6004c3..baa80545 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/RowCacheHolder.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/cache/CacheHolder.java
@@ -13,9 +13,9 @@ import java.io.Serializable;
* @version 1.0.0
* @since 2023/6/25 14:21
*/
-public class RowCacheHolder {
+public class CacheHolder {
- private RowCacheHolder() {
+ private CacheHolder() {
}
/**
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/query/CacheQuery.java b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/query/CacheQuery.java
index 13338a37..6f7eaba7 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/query/CacheQuery.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-mybatis/src/main/java/com/orion/ops/framework/mybatis/core/query/CacheQuery.java
@@ -3,7 +3,7 @@ package com.orion.ops.framework.mybatis.core.query;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.orion.lang.define.wrapper.Store;
import com.orion.lang.utils.Valid;
-import com.orion.ops.framework.mybatis.core.cache.RowCacheHolder;
+import com.orion.ops.framework.mybatis.core.cache.CacheHolder;
import java.io.Serializable;
import java.util.Optional;
@@ -76,14 +76,14 @@ public class CacheQuery {
// 不查询缓存
if (!force) {
// 从缓存中获取
- Store store = RowCacheHolder.get(mapperClass, id);
+ Store store = CacheHolder.get(mapperClass, id);
return Optional.ofNullable(store)
.map(Store::get);
}
// 查询
T row = dao.selectById(id);
// 设置缓存
- RowCacheHolder.set(mapperClass, id, row);
+ CacheHolder.set(mapperClass, id, row);
return Optional.ofNullable(row);
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/OrionSecurityAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/OrionSecurityAutoConfiguration.java
index d4dde797..1d891152 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/OrionSecurityAutoConfiguration.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/OrionSecurityAutoConfiguration.java
@@ -163,11 +163,13 @@ public class OrionSecurityAutoConfiguration {
/**
* @param adminSeverContextPath adminSeverContextPath
+ * @param managementEndpoints managementEndpoints
* @return 控制台安全策略
*/
@Bean
- public ConsoleAuthorizeRequestsCustomizer consoleAuthorizeRequestsCustomizer(@Value("${spring.boot.admin.context-path:''}") String adminSeverContextPath) {
- return new ConsoleAuthorizeRequestsCustomizer(adminSeverContextPath);
+ public ConsoleAuthorizeRequestsCustomizer consoleAuthorizeRequestsCustomizer(@Value("${spring.boot.admin.context-path:''}") String adminSeverContextPath,
+ @Value("${management.endpoints.web.base-path:''}") String managementEndpoints) {
+ return new ConsoleAuthorizeRequestsCustomizer(adminSeverContextPath, managementEndpoints);
}
/**
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/AuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/AuthorizeRequestsCustomizer.java
similarity index 91%
rename from orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/AuthorizeRequestsCustomizer.java
rename to orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/AuthorizeRequestsCustomizer.java
index fb03bdc9..f6d33178 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/config/AuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/AuthorizeRequestsCustomizer.java
@@ -1,4 +1,4 @@
-package com.orion.ops.framework.security.config;
+package com.orion.ops.framework.security.core.strategy;
import org.springframework.core.Ordered;
import org.springframework.security.config.Customizer;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConfigAuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConfigAuthorizeRequestsCustomizer.java
index 8b1c601b..4a97ce75 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConfigAuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConfigAuthorizeRequestsCustomizer.java
@@ -1,6 +1,5 @@
package com.orion.ops.framework.security.core.strategy;
-import com.orion.ops.framework.security.config.AuthorizeRequestsCustomizer;
import com.orion.ops.framework.security.config.SecurityConfig;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConsoleAuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConsoleAuthorizeRequestsCustomizer.java
index b8ddc75b..f70ff3ce 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConsoleAuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/ConsoleAuthorizeRequestsCustomizer.java
@@ -1,6 +1,5 @@
package com.orion.ops.framework.security.core.strategy;
-import com.orion.ops.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
@@ -15,8 +14,11 @@ public class ConsoleAuthorizeRequestsCustomizer extends AuthorizeRequestsCustomi
private final String adminSeverContextPath;
- public ConsoleAuthorizeRequestsCustomizer(String adminSeverContextPath) {
+ private final String managementEndpoints;
+
+ public ConsoleAuthorizeRequestsCustomizer(String adminSeverContextPath, String managementEndpoints) {
this.adminSeverContextPath = adminSeverContextPath;
+ this.managementEndpoints = managementEndpoints;
}
@Override
@@ -28,7 +30,7 @@ public class ConsoleAuthorizeRequestsCustomizer extends AuthorizeRequestsCustomi
// druid 监控
.antMatchers("/druid/**").anonymous()
// actuator 安全配置 TODO TEST
- .antMatchers("/actuator", "/actuator/**").anonymous()
+ .antMatchers(managementEndpoints, managementEndpoints + "/**").anonymous()
// admin 安全配置 TODO TEST
.antMatchers(adminSeverContextPath, adminSeverContextPath + "/**").anonymous();
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/PermitAllAnnotationAuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/PermitAllAnnotationAuthorizeRequestsCustomizer.java
index cb1ba768..372780c1 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/PermitAllAnnotationAuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/PermitAllAnnotationAuthorizeRequestsCustomizer.java
@@ -1,6 +1,5 @@
package com.orion.ops.framework.security.core.strategy;
-import com.orion.ops.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.context.ApplicationContext;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/StaticResourceAuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/StaticResourceAuthorizeRequestsCustomizer.java
index 977a360b..aafa431f 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/StaticResourceAuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/StaticResourceAuthorizeRequestsCustomizer.java
@@ -1,6 +1,5 @@
package com.orion.ops.framework.security.core.strategy;
-import com.orion.ops.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.http.HttpMethod;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/WebsocketAuthorizeRequestsCustomizer.java b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/WebsocketAuthorizeRequestsCustomizer.java
index 677974d7..2a7732f2 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/WebsocketAuthorizeRequestsCustomizer.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-security/src/main/java/com/orion/ops/framework/security/core/strategy/WebsocketAuthorizeRequestsCustomizer.java
@@ -1,6 +1,5 @@
package com.orion.ops.framework.security.core.strategy;
-import com.orion.ops.framework.security.config.AuthorizeRequestsCustomizer;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configurers.ExpressionUrlAuthorizationConfigurer;
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java
index 47a0e3b2..c2e91ce1 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/config/OrionWebAutoConfiguration.java
@@ -3,9 +3,15 @@ package com.orion.ops.framework.web.config;
import com.alibaba.fastjson.serializer.SerializerFeature;
import com.alibaba.fastjson.support.config.FastJsonConfig;
import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import com.fasterxml.jackson.annotation.JsonInclude;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.module.SimpleModule;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
import com.orion.lang.utils.collect.Lists;
import com.orion.ops.framework.common.constant.FilterOrderConst;
import com.orion.ops.framework.common.filter.FilterCreator;
+import com.orion.ops.framework.web.core.convert.CustomerFastJsonHttpMessageConverter;
+import com.orion.ops.framework.web.core.convert.SerializeConfig;
import com.orion.ops.framework.web.core.filter.TraceIdFilter;
import com.orion.ops.framework.web.core.handler.GlobalExceptionHandler;
import com.orion.ops.framework.web.core.handler.WrapperResultHandler;
@@ -13,11 +19,13 @@ import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.AutoConfiguration;
import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty;
import org.springframework.boot.autoconfigure.http.HttpMessageConverters;
+import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.boot.web.servlet.FilterRegistrationBean;
import org.springframework.context.annotation.Bean;
import org.springframework.http.MediaType;
import org.springframework.http.converter.ByteArrayHttpMessageConverter;
import org.springframework.http.converter.HttpMessageConverter;
+import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter;
import org.springframework.util.AntPathMatcher;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.cors.CorsConfiguration;
@@ -40,6 +48,7 @@ import java.util.List;
* @since 2023/6/16 16:26
*/
@AutoConfiguration
+@EnableConfigurationProperties(SerializeConfig.class)
public class OrionWebAutoConfiguration implements WebMvcConfigurer {
@Value("${orion.api.prefix}")
@@ -70,12 +79,13 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
}
/**
- * @return http message json 转换器
+ * @param serializeConfig 序列化配置
+ * @return http message fast json 转换器
*/
@Bean
- public FastJsonHttpMessageConverter fastJsonHttpMessageConverter() {
+ public FastJsonHttpMessageConverter fastJsonHttpMessageConverter(SerializeConfig serializeConfig) {
// json 转换器
- FastJsonHttpMessageConverter converter = new FastJsonHttpMessageConverter();
+ CustomerFastJsonHttpMessageConverter converter = new CustomerFastJsonHttpMessageConverter(serializeConfig);
// 配置
FastJsonConfig config = new FastJsonConfig();
// 支持的类型
@@ -101,21 +111,49 @@ public class OrionWebAutoConfiguration implements WebMvcConfigurer {
return converter;
}
+ /**
+ * @return http message jackson 转换器
+ */
+ @Bean
+ public MappingJackson2HttpMessageConverter mappingJackson2HttpMessageConverter() {
+ MappingJackson2HttpMessageConverter converter = new MappingJackson2HttpMessageConverter();
+ // 支持的类型
+ List mediaTypes = Lists.of(
+ MediaType.APPLICATION_JSON,
+ MediaType.APPLICATION_FORM_URLENCODED,
+ MediaType.APPLICATION_XHTML_XML,
+ MediaType.TEXT_PLAIN,
+ MediaType.TEXT_HTML,
+ MediaType.TEXT_XML,
+ new MediaType("application", "vnd.spring-boot.actuator.v2+json")
+ );
+ converter.setSupportedMediaTypes(mediaTypes);
+ ObjectMapper objectMapper = converter.getObjectMapper();
+ objectMapper.setSerializationInclusion(JsonInclude.Include.NON_NULL);
+ // 序列化配置
+ SimpleModule module = new SimpleModule();
+ module.addSerializer(Long.class, ToStringSerializer.instance);
+ module.addSerializer(Long.TYPE, ToStringSerializer.instance);
+ objectMapper.registerModule(module);
+ return converter;
+ }
+
/**
* @return http message 转换器列表
*/
@Bean
- public HttpMessageConverters httpMessageConverters(FastJsonHttpMessageConverter jsonConverter) {
- // 先获取默认转换器
+ public HttpMessageConverters httpMessageConverters(FastJsonHttpMessageConverter fastJsonConverter,
+ MappingJackson2HttpMessageConverter jacksonConvert) {
List> defaultConverters = new HttpMessageConverters().getConverters();
List> converters = new ArrayList<>();
// 将 byte converter 添加至首位 - fix swagger api 返回base64报错
converters.add(new ByteArrayHttpMessageConverter());
- // 添加自定义 converter - using WrapperResultHandler
- converters.add(jsonConverter);
- // 添加默认 converter
+ // 添加自定义 converter - using WrapperResultHandler/脱敏
+ converters.add(fastJsonConverter);
+ // 添加自定义 converter - jackson
+ converters.add(jacksonConvert);
+ // 添加默认处理器
converters.addAll(defaultConverters);
- // 设置不添加默认 converter
return new HttpMessageConverters(false, converters);
}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/CustomerFastJsonHttpMessageConverter.java b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/CustomerFastJsonHttpMessageConverter.java
new file mode 100644
index 00000000..856d296d
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/CustomerFastJsonHttpMessageConverter.java
@@ -0,0 +1,40 @@
+package com.orion.ops.framework.web.core.convert;
+
+import com.alibaba.fastjson.support.spring.FastJsonHttpMessageConverter;
+import org.springframework.http.MediaType;
+
+import java.lang.reflect.Type;
+import java.util.List;
+
+/**
+ * 自定义 fastjson 转换器
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2023/7/11 11:46
+ */
+public class CustomerFastJsonHttpMessageConverter extends FastJsonHttpMessageConverter {
+
+ private final SerializeConfig serializeConfig;
+
+ public CustomerFastJsonHttpMessageConverter(SerializeConfig serializeConfig) {
+ this.serializeConfig = serializeConfig;
+ }
+
+ @Override
+ public boolean canRead(Type type, Class> contextClass, MediaType mediaType) {
+ List unsupportedClasses = serializeConfig.getUnsupportedClasses();
+ if (unsupportedClasses != null) {
+ if (unsupportedClasses.contains(contextClass.getName())) {
+ return false;
+ }
+ }
+ return super.canRead(type, contextClass, mediaType);
+ }
+
+ @Override
+ public boolean canWrite(Type type, Class> clazz, MediaType mediaType) {
+ return super.canWrite(type, clazz, mediaType);
+ }
+
+}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/SerializeConfig.java b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/SerializeConfig.java
new file mode 100644
index 00000000..d2c4d7c3
--- /dev/null
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/java/com/orion/ops/framework/web/core/convert/SerializeConfig.java
@@ -0,0 +1,29 @@
+package com.orion.ops.framework.web.core.convert;
+
+import lombok.Data;
+import org.springframework.boot.context.properties.ConfigurationProperties;
+
+import java.util.ArrayList;
+import java.util.List;
+
+/**
+ * 序列化配置
+ *
+ * @author Jiahang Li
+ * @version 1.0.0
+ * @since 2023/7/11 14:57
+ */
+@Data
+@ConfigurationProperties("orion.serializer")
+public class SerializeConfig {
+
+ /**
+ * 不支持的序列化类型
+ */
+ private List unsupportedClasses;
+
+ public SerializeConfig() {
+ this.unsupportedClasses = new ArrayList<>();
+ }
+
+}
diff --git a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/resources/META-INF/spring-configuration-metadata.json b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/resources/META-INF/spring-configuration-metadata.json
index b506adc4..e6639d6f 100644
--- a/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/resources/META-INF/spring-configuration-metadata.json
+++ b/orion-ops-framework/orion-ops-spring-boot-starter-web/src/main/resources/META-INF/spring-configuration-metadata.json
@@ -14,6 +14,11 @@
"name": "orion.api.cors",
"type": "java.lang.Boolean",
"description": "是否开启 cors 过滤器."
+ },
+ {
+ "name": "orion.serializer.unsupported-classes",
+ "type": "java.util.List",
+ "description": "不支持的序列化类型."
}
]
}
\ No newline at end of file
diff --git a/orion-ops-framework/pom.xml b/orion-ops-framework/pom.xml
index 032d3b24..25fd3ca0 100644
--- a/orion-ops-framework/pom.xml
+++ b/orion-ops-framework/pom.xml
@@ -29,6 +29,7 @@
orion-ops-spring-boot-starter-log
orion-ops-spring-boot-starter-storage
orion-ops-spring-boot-starter-security
+ orion-ops-spring-boot-starter-monitor
\ No newline at end of file
diff --git a/orion-ops-launch/pom.xml b/orion-ops-launch/pom.xml
index 4c2cbfa4..d531d7e2 100644
--- a/orion-ops-launch/pom.xml
+++ b/orion-ops-launch/pom.xml
@@ -77,6 +77,10 @@
com.orion.ops
orion-ops-spring-boot-starter-security
+
+ com.orion.ops
+ orion-ops-spring-boot-starter-monitor
+
diff --git a/orion-ops-launch/src/main/resources/application.yaml b/orion-ops-launch/src/main/resources/application.yaml
index feca6a35..3dd6bbf5 100644
--- a/orion-ops-launch/src/main/resources/application.yaml
+++ b/orion-ops-launch/src/main/resources/application.yaml
@@ -67,6 +67,20 @@ spring:
output:
ansi:
enabled: DETECT
+ boot:
+ admin:
+ context-path: /admin
+ client:
+ url: http://127.0.0.1:${server.port}/${spring.boot.admin.context-path}
+ instance:
+ service-host-type: IP
+
+management:
+ endpoints:
+ web:
+ base-path: /actuator
+ exposure:
+ include: '*'
mybatis-plus:
configuration:
@@ -106,32 +120,26 @@ logging:
max-file-size: 16MB
total-size-cap: 0B
pattern:
- console: '%clr(%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %boldBlue([%X{tid}]) %clr([%15.15t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}'
+ console: '%clr(%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}}){faint} %clr(${LOG_LEVEL_PATTERN:-%5p}) %boldBlue([%X{tid}]) %clr([%22.22t]){faint} %clr(%-40.40logger{39}){cyan} %clr(:){faint} %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}'
file: "%d{${LOG_DATEFORMAT_PATTERN:yyyy-MM-dd HH:mm:ss.SSS}} ${LOG_LEVEL_PATTERN:-%5p} [%X{tid}] [%t] %-40.40logger{39} : %m%n${LOG_EXCEPTION_CONVERSION_WORD:%wEx}"
- printer:
- mode: PRETTY
- expression: 'execution (* com.orion.ops.**.controller.*.*(..)) && !@annotation(com.orion.ops.framework.common.annotation.IgnoreLog)'
- headers:
- - user-agent,accept
- - content-type
- field:
- ignore:
- - password,newPassword
- - metrics
- desensitize:
- - phone,phoneNumber
- - email,sendEmail
+ level:
+ com.orion.ops.launch.controller.BootstrapController: INFO
orion:
# 版本
version: @revision@
- # api 信息
api:
# 公共api前缀
prefix: /orion-api
# 是否开启跨域
cors: true
+ serializer:
+ # 不支持的序列化类型
+ unsupported-classes:
+ - de.codecentric.boot.admin.server.web.InstancesController
+ - org.springframework.boot.actuate.endpoint.web.servlet.AbstractWebMvcEndpointHandlerMapping$OperationHandler
swagger:
+ # swagger 配置
title: orion-ops-pro 运维平台
description: 一站式运维服务平台
version: ${orion.version}
@@ -139,7 +147,23 @@ orion:
email: ljh1553488six@139.com
license: Apache-2.0
license-url: https://github.com/lijiahangmax/orion-ops-pro/blob/main/LICENSE
+ logging:
+ # 全局日志打印
+ printer:
+ mode: PRETTY
+ expression: 'execution (* com.orion.ops.**.controller.*.*(..)) && !@annotation(com.orion.ops.framework.common.annotation.IgnoreLog)'
+ headers:
+ - user-agent,accept
+ - content-type
+ field:
+ ignore:
+ - password,newPassword
+ - metrics
+ desensitize:
+ - phone,phoneNumber
+ - email,sendEmail
storage:
+ # 本地文件存储
local:
enabled: true
name-append-trace-id: true
@@ -160,3 +184,10 @@ orion:
secret-key: I66AndrKWrwXjtBL
use-generator-key: true
generator-key-length: 128
+ thread:
+ # 线程池配置
+ pool:
+ core-pool-size: 2
+ max-pool-size: 4
+ keep-alive-seconds: 180
+ queue-capacity: 30