Springboot - 监控模块Admin(springboot-satrter-admin)未生效及解决办法

                      

    Spring Boot Admin是一个开源社区项目,用于管理和监控SpringBoot应用程序。 应用程序作为Spring Boot Admin Client向为Spring Boot Admin Server注册(通过HTTP)或使用SpringCloud注册中心(例如Eureka,Consul)发现。 UI是的AngularJs应用程序,展示Spring Boot Admin Client的Actuator端点上的一些监控。

    强大之处是毋庸置疑的,但是在我本地出现了一次‘秃然’ 失效的问题,也是让人啼笑皆非。。。

    问题出现在一次本地依赖jar包整理之后,使用IDEA查看所依赖的第三方库的时候,发现springboot-starter-web所支持的Restfull已经被我们改成了MQTT的方式通讯,那就意味这是否可以将这个web包剔除掉吗;当然,剔除掉后,对项目的编译、打包、启动、运行都是毫无影响的,但是偏偏Spring Boot Admin Server再也收不到这个项目的监控消息了,而且这个项目也不报异常啥的。。。

    没办法,只好在查一查这个Spring Boot Admin到底是怎样用的,果然让我们查到了问题排查的大致原因;

    再结合项目中的springboot-starter-admin失效的时间跟代码提交时间对比,基本上是吻合的;

    加上spring-boot-starter-web之后,问题就解决了,应该是Admin是通过发送restful请求到项目的HTTP接口,来调用需要监控的各个性能指标的,这些功能都是需要依赖web包的,移除后就不能正常的提供这些接口服务,那Admin Server 端也就无法获取项目的信息,虽然项目也没有异常出现。。。

    完整配置如下:POM依赖 + application.yml配置

              <dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
			<version>${springboot.version}</version>
		</dependency>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-web</artifactId>
			<version>${springboot.version}</version>
		</dependency>
		<dependency>
			<groupId>de.codecentric</groupId>
			<artifactId>spring-boot-admin-starter-client</artifactId>
			<version>2.1.6</version>
		</dependency>
spring:
    boot:
        admin:
            client:
                url: http://127.0.0.1:8866
                instance:
                    name: http-server-xxxx
management:
    endpoints:
        web:
            exposure:
                include: '*'
    endpoint:
        health:
            show-details: always
        shutdown:
            enabled: true
    security:
        enabled: false

 

posted @ 2022-01-27 18:35  zhangdaopin  阅读(1249)  评论(0编辑  收藏  举报