java - /actuator/info 端点不适用于 spring boot 2.5.0
问题描述
我将应用程序中的 spring boot 版本从 2.4.4 升级到了 2.5.0,它停止暴露 /actuator/info 端点。这是 pom.xml 和 application.yml
pom.xml
<?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.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.5.0</version>
<relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.ms</groupId>
<artifactId>spring-boot-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot-test</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>11</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<layers>
<enabled>true</enabled>
</layers>
</configuration>
<executions>
<execution>
<goals>
<goal>repackage</goal>
<goal>build-info</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
应用程序.yml
management:
endpoints:
jmx:
exposure:
include: "health,info"
使用 Spring Boot 父版本 2.4.4,应用程序能够公开信息端点,但不能使用 2.5.0。
解决方案
通过 http 公开执行器 url 的正确属性是management.endpoints.web.exposure.exclude
(web
而不是jmx
)。
在您的情况下,info
较早暴露不是因为您拥有您提供的属性,而是因为它默认暴露(与 一起health
)。但是在 2.5.0 中它变成了 hidden,所以现在你需要手动公开它。
推荐阅读
- debian - tshark "--export-objects" 不起作用,与手册页相反
- java - android中带有溢出事件的自定义日历视图
- php - 删除 Resource::Collection 中的空数组不起作用 Laravel
- javascript - iife 如何帮助变量名冲突和不污染全局范围(与常规的非 iife 函数相反)?
- java - 构建 cas (SSO) apereo 中的错误
- node.js - 从节点 twitter 获取完整的推文
- php - 如何使用 AJAX、PHP 和 MySQL 使过滤器协同工作
- javascript - 如何重新分配函数参数
- javascript - Javascript中的didSet:更改变量时调用函数
- google-app-maker - Appmaker multiple filters on one page