打开“/actuator/mappings”时得到 "Whitelabel Error Page"

Getting "Whitelabel Error Page" when opening "/actuator/mappings"

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

客户端的代码如下:

@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>

这是客户项目结构:

bootstrap.properties:

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

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

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

spring-boot-actuator jar version = 2.1.3

从 Spring 启动 2.x 开始,除少数非敏感端点(如 /health 和 /info 默认情况下)外,所有执行器端点都被禁用。

您可以使用 属性 management.endpoints.web.exposure.include=*

启用它们

详情请参考here

Default management.endpoints.web.exposure.include, info, health
由于默认提供 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.

Enable/Disable 端点

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

Spring boot 2.x :: 默认情况下仅公开健康和信息,为了公开其他执行器端点,请提及端点名称或添加以下行以公开所有端点。

management.endpoints.web.exposure.include: '*'