/执行器/信息 终结点在弹簧引导 2.5.0 下不起作用

2022-09-03 09:09:51

我将应用程序中的弹簧启动版本从2.4.4升级到2.5.0,它停止公开/执行器/info端点。这是pom.xml和appplication.yml

啪.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。


答案 1

通过 http 公开执行器 url 的正确属性是 ( 而不是 )。management.endpoints.web.​exposure.excludewebjmx

在你的情况下,之前公开不是因为你拥有你提供的属性,而是因为它默认公开(以及 )。但是在2.5.0中,它被隐藏了,所以现在你需要手动公开它。infohealth


答案 2

将其添加到应用程序属性以公开 /info 终结点。

management.info.env.enabled = true

推荐