MS-*_*MS- 2 java spring spring-boot
我将应用程序中的 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>
Run Code Online (Sandbox Code Playgroud)
应用程序.yml
management:
endpoints:
jmx:
exposure:
include: "health,info"
Run Code Online (Sandbox Code Playgroud)
使用 spring boot 父版本 2.4.4,应用程序能够公开信息端点,但不能使用 2.5.0。
cod*_*key 26
将其添加到应用程序属性以公开 /info 端点。
management.info.env.enabled = true
Run Code Online (Sandbox Code Playgroud)
Sus*_*afa 12
就我而言,这是一个愚蠢的错误,我有以下依赖性:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
代替:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
因此,我不断收到 Whitelabel 错误页面 404 在所有 /actuator 调用中未找到
在应用程序属性中
#Actuator
management.endpoints.jmx.exposure.include=health,info,env,beans
management.endpoints.web.exposure.include=health,info,env,beans
Run Code Online (Sandbox Code Playgroud)
您必须启用management.info.env.enabled true并且可以在属性文件中添加您想要的任何类型的详细信息。像下面这样。并确保启用infoweb.exposure。所有配置如下。
#enable /actuator/info
management.info.env.enabled=true
management.endpoints.web.exposure.include=info
#custom properties
info.app.name=order-service
info.app.version=1.0.0
info.app.description=you can insert any kind of data in the property file like this
info.author=mafei
Run Code Online (Sandbox Code Playgroud)
#enable /actuator/info
management:
info:
env:
enabled: true
endpoints:
web:
exposure:
include: info
#custom properties
info:
app:
name: order-service
version: 1.0.0
description: you can insert any kind of data in the property file like this
author: mafei
Run Code Online (Sandbox Code Playgroud)
您可以在此处查看结果。
通过 http 公开执行器 url 的正确属性是management.endpoints.web.?exposure.exclude(web而不是jmx)。
在您的情况下,info较早公开不是因为您拥有您提供的属性,而是因为它默认公开(以及health)。但是在 2.5.0 中它变成了 hidden,所以现在你需要手动公开它。
| 归档时间: |
|
| 查看次数: |
734 次 |
| 最近记录: |