spring-boot - 打开 "Whitelabel Error Page"时获取 "/actuator/mappings"

标签 spring-boot spring-boot-actuator

我是 spring-cloud 的新手,所以我正在使用视频教程,因此要阅读公开的端点,我尝试打开 http://localhost:8000/actuator/mappings但它对我不起作用,但/health 网址给了我以下结果:

enter image description here

这是客户端编写的代码:

@RefreshScope
@RestController
class MessageRestController {

  @Value("${message}")
  private String message;

  @RequestMapping("/message")
  String getMessage() {
      return this.message;
  }
 }

pom.xml:

<parent>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-parent</artifactId>
    <version>2.1.3.RELEASE</version>
    <relativePath/> <!-- lookup parent from repository -->
</parent>
<groupId>com.spring.cloud.reservation</groupId>
<artifactId>reservation-service</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>reservation-service</name>
<description>Demo project for Spring Boot</description>
<properties>
    <java.version>1.8</java.version>
    <spring-cloud.version>Greenwich.SR1</spring-cloud.version>
</properties>
<dependencies>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-jpa</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-actuator</artifactId>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-data-rest</artifactId>
    </dependency>
   <dependency>
        <groupId>org.springframework.cloud</groupId>
        <artifactId>spring-cloud-starter-config</artifactId>
    </dependency>
    <dependency>
        <groupId>com.h2database</groupId>
        <artifactId>h2</artifactId>
        <scope>runtime</scope>
    </dependency>
    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-test</artifactId>
        <scope>test</scope>
    </dependency>
</dependencies>

<dependencyManagement>
    <dependencies>
        <dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-dependencies</artifactId>
            <version>${spring-cloud.version}</version>
            <type>pom</type>
            <scope>import</scope>
        </dependency>
    </dependencies>
</dependencyManagement>

<build>
    <plugins>
        <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
        </plugin>
    </plugins>
</build>

这是客户项目结构:

enter image description here

bootstrap.properties:

spring.application.name=reservation-service
spring.cloud.config.uri=http://localhost:8888

在/refresh 上执行 Post 时给出:未找到错误

curl -d {} http://localhost:8000/actuator/refresh

enter image description here

spring-boot-actuator jar 版本 = 2.1.3

最佳答案

默认 management.endpoints.web.exposure.include、信息、健康
由于默认提供actuator/health和actuator/info,您将获得信息

management.endpoints.web.exposure.include = * //will allow all endpoints to be exposed

management.endpoints.web.exposure.include=health,info # Endpoint IDs that should be included or '*' for all.
management.endpoints.web.exposure.exclude= # Endpoint IDs that should be excluded or '*' for all.
management.endpoints.web.base-path=/actuator # Base path for Web endpoints. Relative to server.servlet.context-path or management.server.servlet.context-path if management.server.port is configured.
management.endpoints.web.path-mapping= # Mapping between endpoint IDs and the path that should expose them.

保护端点

management.endpoint.health.roles= # Roles used to determine whether or not a user is authorized to be shown details. When empty, all authenticated users are authorized. //for health

management.endpoint.health.show-details=always,never # When to show full health details.

启用/禁用端点

management.endpoint.(endpointName).enabled=true # Whether to enable the health endpoint.
e.g. management.endpoint.health.enabled=true

关于spring-boot - 打开 "Whitelabel Error Page"时获取 "/actuator/mappings",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55399978/

相关文章:

spring-boot - Java 11 + QueryDSL 4 + Gradle 5 + SpringBoot 2.1- 不生成 QClasses

java - 使用java或spring框架如何让两个应用程序一直交换心跳?

Spring 执行器 "/actuator"端点不可用

java - 如何在 spring boot 中使用 findAll 方法与 crudrepository

grails - Grails 3 中的拆分配置

java - 更改 Spring Boot 2.1.2 上文件上传的大小限制

java - Spring-Boot 中 application.properties 属性的 UTF-8 编码

Java Spring Boot Actuator Metrics系统负载平均值返回-1

spring-boot - 如何配置 Spring Boot logback RollingFileAppender 并拥有执行器日志文件?

java - 在 Spring Boot/执行器根端点上返回 404