做网站站长先把作息和身体搞好,天网网站建设,黑河市建设局网站,酷玛网站建设小Hub领读#xff1a;服务都需要监控#xff0c;SpringBoot项目中#xff0c;你常用哪些监控模块呢#xff1f;actuator?admin?作者#xff1a;小小____https://segmentfault.com/a/1190000022945443当一个 Spring Boot 应用运行的时候#xff0c;开发者需要对 Spring … 小Hub领读服务都需要监控SpringBoot项目中你常用哪些监控模块呢actuator?admin?作者小小____https://segmentfault.com/a/1190000022945443当一个 Spring Boot 应用运行的时候开发者需要对 Spring Boot 应用进行实时监控获得项目的报警需求Spring Boot 提供了actuator 来帮助开发者获取应用程序运行时的数据。在 Spring Boot 中添加端点配置相当的简单。只需要添加 spring-boot-starter-actuator添加相关的依赖org.springframework.bootspring-boot-starter-actuator2.3.1.RELEASE常用的端点如下常用端点列举如下可以一个个详细试一下/info 应用基本信息/health 健康度信息/metrics 运行指标/env 环境变量信息/loggers 日志相关/dump 线程相关信息/trace 请求调用轨迹这些端点大都是默认开启的如果想要开启一个端点需要在配置文件中配置以下内容。endpoints: metrics: sensitive: false此时 sensitive 是关闭的。举个例子这里举个例子访问是否在线的接口localhost:8080/actuator/health此时浏览器的输出结果为端点响应缓存对于一些不带参数的端点将会进行缓存。搜索公众号MarkerHub关注回复[vue]获取前后端入门教程management: endpoint: auditevents: cache: time-to-live: 100s上方的配置说明了缓存达到 100s路径映射可以对访问的路径进行映射。management: endpoints: web: base-path: / path-mapping: health: healthcheck此时访问路径由原先的 localhost:8080/actuator/health 转变为 localhost:8080/healthcheckCORS进行跨域操作。可以通过配置文件快速的开启 CORS 支持。management: endpoints: web: cors: allowed-origins: http: allowed-methods: *在上方中允许处理来自 http://localhost:8091 的任何请求允许的方法任意。添加相关的依赖。de.codecentricspring-boot-admin-starter-server2.2.3在启动类上增加相关的注解package com.example.demo;import de.codecentric.boot.admin.server.config.EnableAdminServer;import org.springframework.boot.SpringApplication;import org.springframework.boot.autoconfigure.SpringBootApplication;SpringBootApplicationEnableAdminServerpublic class DemoApplication {public static void main(String[] args) { SpringApplication.run(DemoApplication.class, args); }}配置完成以后输入链接进行访问。http:再次添加 client 端de.codecentricspring-boot-admin-starter-client2.2.3书写配置文件spring: boot: admin: client: url: http:此时查看 admin查看其健康度(完)好文章点个在看