spring boot 学习 ---- spring boot admin

什么是Spring Boot Admin

Spring Boot Admin 是一个管理和监控Spring Boot 应用程序的开源软件,Spring Boot Admin 的GitHub地址 https://github.com/codecentric/spring-boot-admin 他是一个基于C/S架构的实现。它可以通过HTTP或者Eureka注册到admin server中进行展示,通过它可以监控到每个程序或微服务对机器资源的使用情况。

使用Spring Boot Admin 监控单体应用

使用Spring Boot Admin 监控单体应用需要创建两个或两个以上的应用,其中一个充当服务器端。其他的则是客户端。

Admin Server

Admin Server 需要添加的maven依赖如下
Admin需要添加以下依赖

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-server</artifactId>
            <version>2.1.3</version>
        </dependency>

Admin需要在启动类上添加注解@EnableAdminServer

@SpringBootApplication
@EnableAdminServer
public class AdminServerApplication {

    public static void main(String[] args) {
        SpringApplication.run(AdminServerApplication.class, args);
    }

}

Admin Client

Admin Client 需要添加的依赖如下

        <dependency>
            <groupId>de.codecentric</groupId>
            <artifactId>spring-boot-admin-starter-client</artifactId>
            <version>2.1.0</version>
        </dependency>

接下来需要填写配置文件

server.port=8080
# 修改Admin Server的地址
spring.boot.admin.client.url=http://localhost:8000
# 打开客户端Actuator的监控
management.endpoints.web.exposure.include=*

之后我们可以启动项目了
之后我们可以打开浏览器输入localhost:8000查看我们的spring boot admin 的监控中心了。

猜你喜欢

转载自www.cnblogs.com/bananafish/p/10632962.html