blog: Spring Boot - Actuator Web 访问开启

1. 概述

  1. 打开 Spring Boot Actuator 的 Web 访问

2. 场景

  1. 之前看 Spring 的时候, 曾经想了解当时的配置
  2. 后来发现, 确实有这么个工具
  3. 刚开始发现, 除了 actuator, 别的也看不了什么

3. 环境

  1. os

    1. win10
  2. jdk
    1. 1.8
  3. ide
    1. ida 2018.1
  4. spring
    1. spring boot

      1. 2.0.4 release
    2. 组件
      1. thymeleaf
      2. starter-web
      3. devtool
      4. starter-test
      5. actuator
  5. browser
    1. firefox

      1. 70.0
  6. ref
    1. spring boot in action

4. 问题

  1. 参考书

    1. ref

      1. spring boot in action
    2. 书上说
      1. 书上列了一堆 url

        1. 感觉可以看很多事
  2. 问题
    1. 我试了一圈, 就 3 个 url 能用

      1. \actuator
      2. \health
      3. \info
  3. 但是书上给我的感觉, 好像都是配上就好了
    1. 也不知道为啥
    2. 又要开始找开关

5. 解决

  1. 尝试找 官方文档

    1. 找到了 api

      1. ref

        1. Spring Boot Actuator: Production-ready features
    2. 看到了 清一色的 Yes
      1. 我陷入了沉思

        1. 为啥我就脸黑老是
  2. 再往下看
    1. 发现了另一个表格

      1. 发现 yes 的都是 jmx
      2. 而 web 那块, 又都是 清一色的 no
    2. 好了, 确认是配置没开
      1. 那到底怎么打开呢

6. 开关

  1. 配置

    management.endpoints.web.exposure.include=*
  2. 重启
  3. 结果
    1. 管理 url 都可以访问了

7. 其他

  1. actuator 的访问方式

    1. jmx
    2. web
  2. enable 和 expose
    1. 概述

      1. 这俩概念, 我一开始搞混了
    2. enable
      1. 解释

        1. 开启

          1. 开启, 是 jmx 和 web 访问的前提
    3. expose
      1. 解释

        1. 暴露

          1. 需要开启
          2. 只有暴露对应方式, 才可以访问
      2. exclude 和 include
        1. exclude

          1. 排除特定的 url
        2. include
          1. 开启特定的 url
  3. 配置
    1. 默认配置

      # 结合官方文档上面的表格, jmx 确实全开, web 确实只开了 info 和 health
      management.endpoints.jmx.exposure.exclude=*
      management.endpoints.jmx.exposure.include=*
      management.endpoints.web.exposure.exclude=*
      management.endpoints.web.exposure.include=info, health
    2. 配置
      1. 思路

        1. 文档上解释的, 是 exclude 优先
        2. 但是实际上看起来, 是 后面的配置, 会覆盖前面的配置
      2. 具体的配置, 我也不细说了

ps

  1. ref

    1. Spring Boot & Actuator
  2. 其他
    1. 感觉这玩意, 功能还很多, 以后可以仔细学学

原文地址:https://www.cnblogs.com/xy14/p/11781269.html

时间: 2024-08-01 18:14:35

blog: Spring Boot - Actuator Web 访问开启的相关文章

Spring Boot示例 - 1. 使用Spring Boot Actuator构建RESTful web service

一.概述 Spring Boot Actuator是Spring Boot的子项目.使用它无需特别配置,即可为应用增加一些生产级别的服务.本教程展示使用Eclipse + Maven来从零开始构建一个RESTful的应用. 该应用作用是访问http://localhost:8080/fuck?name=xxx,会返回json字符串,并且访问http://localhost:8080/metrics 可以看到应用堆的一些信息. 什么是Spring Boot Actuator? Actuator是个

SpringBoot实战(十)之使用Spring Boot Actuator构建RESTful Web服务

一.导入依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.

Spring Boot开发Web应用之Thymeleaf篇

前言 Web开发是我们平时开发中至关重要的,这里就来介绍一下Spring Boot对Web开发的支持. 正文 Spring Boot提供了spring-boot-starter-web为Web开发予以支持,spring-boot-starter-web为我们提供了嵌入的Tomcat以及Spring MVC的依赖. 项目结构推荐 一个好的项目结构会让你开发少一些问题,特别是Spring Boot中启动类要放在root package下面,我的web工程项目结构如下: root package结构:

Spring MVC或Spring Boot配置默认访问页面不生效?

相信在开发项目过程中,设置默认访问页面应该都用过.但是有时候设置了却不起作用.你知道是什么原因吗?今天就来说说我遇到的问题. 首先说说配置默认访问页面有哪几种方式. 1.tomcat配置默认访问页面 进入 tomcat 的 conf 目录,编辑 web.xml 文件.在 <web-app></web-app> 添加默认访问页面. <welcome-file-list> <welcome-file>index.html</welcome-file>

spring boot admin + spring boot actuator + erueka 微服务监控

关于spring boot actuator简单使用,请看 简单的spring boot actuator 使用,点击这里 spring boot admin 最新的正式版本是1.5.3 与 springboot 或者spring cloud 新版本不兼容 ,希望大家不要踩坑. 新版的  spring-cloud-netflix-core 1.3.7  移除了一个zuul的自动配置类,spring boot admin 1.5.3刚好引用了这个类. 新版的 spring-cloud-starte

Application Metrics With Spring Boot Actuator

转自:https://bartcode.co.uk/2015/01/application-metrics-with-spring-boot-actuator Update 12/2017: It will need an update/rewrite since Spring Boot 2.0 is coming. Having metrics collected is vital for ...just anything, besides relationships maybe :) My

Spring Boot 整合web层之JSON的使用

Spring Boot对web层进行了一系列的自动化配置,只需要引入web依赖,零配置,就可以直接使用spring  mvc 里面的东西,这篇看一下它对json的自动化配置: 创建一个web项目,勾选web的依赖,就可以看到依赖里面引入了json 在前后端分离的项目中,前后端的交互是通过json格式进行的.那么在Spring Boot中如何使用呢? 我们先看一个消息转化工具(HttpMessageConverter),所用的json生成都离不开它,它的作用: 1.将服务端返回的对象序列化成JSO

(030)Spring Boot之RestTemplate访问web服务案例

每一个springboot工程都可以看做一个服务,这也是微服务的基础,使用RestTemplate访问springboot提供的web服务.如下: String BASE_URL="http://127.0.0.1:8080"; RestTemplate res=new RestTemplate(); String body= res.getForObject(BASE_URL+"/soa/product/20",String.class);//请求服务,返回jso

spring boot actuator专题

spring-boot-starter-actuator模块的实现对于实施微服务的中小团队来说,可以有效地减少监控系统在采集应用指标时的开发量.当然,它也并不是万能的,有时候我们也需要对其做一些简单的扩展来帮助我们实现自身系统个性化的监控需求.下面,在本文中,我们将详解的介绍一些关于spring-boot-starter-actuator模块的内容,包括它的原生提供的端点以及一些常用的扩展和配置方式. /autoconfig:该端点用来获取应用的自动化配置报告,其中包括所有自动化配置的候选项.同