From 431ddb8fcb3a1f9cef21808d10a584a2861b51ce Mon Sep 17 00:00:00 2001 From: JEECG <445654970@qq.com> Date: Tue, 27 May 2025 22:51:25 +0800 Subject: [PATCH] =?UTF-8?q?=E7=B3=BB=E7=BB=9F=E7=9B=91=E6=8E=A7=E7=9A=84?= =?UTF-8?q?=E5=A4=B4=E4=B8=A4=E4=B8=AAtab=E4=B8=8D=E5=A5=BD=E4=BD=BF?= =?UTF-8?q?=EF=BC=8C=E6=8E=A5=E5=8F=A3404---?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../org/jeecg/config/WebMvcConfiguration.java | 28 +++++++++++++------ 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java index 2515f5d03..66b6ae782 100644 --- a/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java +++ b/jeecg-boot/jeecg-boot-base-core/src/main/java/org/jeecg/config/WebMvcConfiguration.java @@ -11,17 +11,16 @@ import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; import io.micrometer.prometheus.PrometheusMeterRegistry; -import org.springframework.beans.factory.InitializingBean; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.config.BeanPostProcessor; -import org.springframework.boot.actuate.trace.http.InMemoryHttpTraceRepository; -import org.springframework.boot.autoconfigure.condition.ConditionalOnBean; +import org.springframework.boot.context.event.ApplicationReadyEvent; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Conditional; import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Primary; +import org.springframework.context.event.EventListener; import org.springframework.http.CacheControl; import org.springframework.http.converter.HttpMessageConverter; import org.springframework.http.converter.json.MappingJackson2HttpMessageConverter; @@ -59,6 +58,14 @@ public class WebMvcConfiguration implements WebMvcConfigurer { @Autowired(required = false) private PrometheusMeterRegistry prometheusMeterRegistry; + /** + * meterRegistryPostProcessor + * for [QQYUN-12558]【监控】系统监控的头两个tab不好使,接口404 + */ + @Autowired(required = false) + @Qualifier("meterRegistryPostProcessor") + private BeanPostProcessor meterRegistryPostProcessor; + /** * 静态资源的配置 - 使得可以从磁盘中读取 Html、图片、视频、音频等 */ @@ -147,12 +154,17 @@ public class WebMvcConfiguration implements WebMvcConfigurer { /** - * 解决metrics端点不显示jvm信息的问题(zyf) + * 监听应用启动完成事件,确保 PrometheusMeterRegistry 已经初始化 + * for [QQYUN-12558]【监控】系统监控的头两个tab不好使,接口404 + * @param event + * @author chenrui + * @date 2025/5/26 16:46 */ - @Bean - @ConditionalOnBean(name = "meterRegistryPostProcessor") - InitializingBean forcePrometheusPostProcessor(BeanPostProcessor meterRegistryPostProcessor) { - return () -> meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, ""); + @EventListener + public void onApplicationReady(ApplicationReadyEvent event) { + if(null != meterRegistryPostProcessor){ + meterRegistryPostProcessor.postProcessAfterInitialization(prometheusMeterRegistry, ""); + } } // /**