简体   繁体   English

Spring boot 2 - Actuator 端点,/beans 端点在哪里

[英]Spring boot 2 - Actuator endpoint, where is /beans endpoint

In a spring boot 2 application I'm trying to access actuator endpoint /beans as I did before in Spring boot 1.5.* applications.在 spring boot 2 应用程序中,我试图访问执行器端点 /beans,就像我之前在 Spring boot 1.5.* 应用程序中所做的那样。 But I'm unable to.但我做不到。 Also, I don't see the endpoint is being created in the log.INFO.此外,我没有在 log.INFO 中看到正在创建端点。

My pom.xml contains:我的 pom.xml 包含:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.0.0.RELEASE</version>
</parent>

<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-data-jpa</artifactId>
    </dependency>

    <dependency>
        <groupId>mysql</groupId>
        <artifactId>mysql-connector-java</artifactId>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-devtools</artifactId>
        <optional>true</optional>
    </dependency>

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

in application.properties I only have info about the databaseconnectivity:在 application.properties 我只有关于数据库连接的信息:

spring.jpa.hibernate.ddl-auto=update
spring.datasource.url=jdbc:mysql://localhost:3306/somedb
spring.datasource.username=someuser
spring.datasource.password=somepass

As mapped endpoints I see in the info logs:作为我在信息日志中看到的映射端点:

/actuator/health
/actuator/info
/actuator

The application is working but no /application/beans endpoint is created.应用程序正在运行,但没有创建 /application/beans 端点。

How come my /beans or /application/beans endpoint is not generated and what should I change to make it exist?为什么我的 /beans 或 /application/beans 端点没有生成,我应该改变什么才能让它存在?

According to the reference documentation this endpoint is no longer exposed via "web" by default. 根据参考文档,默认情况下,此端点不再通过“web”公开。

First, you need to make sure that the "beans" endpoint is actually enabled: 首先,您需要确保实际启用了“beans”端点:

management.endpoint.beans.enabled=true

in your spring-boot-configuration. 在你的spring-boot-configuration中。 Then, you need to include it in the "web" exposure: 然后,您需要将其包含在“网络”曝光中:

management.endpoints.web.exposure.include=beans

or maybe even 或者甚至是

management.endpoints.web.exposure.include=*

See https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints for further information. 有关详细信息,请参阅https://docs.spring.io/spring-boot/docs/2.0.0.RELEASE/reference/htmlsingle/#production-ready-endpoints-enabling-endpoints

For anyone looking for the yaml specification, for Spring Boot v2.7.1 ,对于任何寻找 yaml 规范的人,对于 Spring Boot v2.7.1

 management:
  endpoint:
    beans:
      enabled: true   
  endpoints:
    web:
      exposure:
        include: beans

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM