【问题标题】:spring boot actuator does not work as expected弹簧靴执行器无法按预期工作
【发布时间】:2021-11-12 23:02:35
【问题描述】:

我开始学习 Spring Boot,我刚刚在我的 pom.xml 中导入了我的 spring-actuator。 现在,端点

http://localhost:8080/actuator/health

工作正常,端点在下面

http://localhost:8080/actuator/

显示以下信息:

{"_links":{"self":{"href":"http://localhost:8080/actuator","templated":false},"health":{"href":"http://localhost:8080/actuator/health","templated":false},"health-path":{"href":"http://localhost:8080/actuator/health/{*path}","templated":true}}}

但是,在文件夹中

src/main/resources

我添加了文件

application.properties

其中包含以下属性:

info.app.name=My Super Cool App
info.app.description=A crazy and fun app, yahoo!
info.app.version=1.0.0

我希望上面提到的属性显示在端点下

http://localhost:8080/actuator/info

但是,上面的端点给了我以下错误消息:

This application has no explicit mapping for /error, so you are seeing this as a fallback.

Sat Sep 18 13:03:31 CEST 2021
There was an unexpected error (type=Not Found, status=404).
No message available

我的错误在哪里?

下面,你可以从我的 pom.xml 中找到一段摘录:

<parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.5.4</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>

    <groupId>com.luv2code.springboot.demo</groupId>
    <artifactId>mycoolap</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>mycoolap</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-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
    </dependencies>

非常感谢!

【问题讨论】:

    标签: java spring-boot spring-boot-actuator


    【解决方案1】:

    似乎在我使用的 Spring Boot 版本中,端点 /acturator/info 默认不公开,就像在早期版本的 spring-boot 中一样。

    为了公开它,我添加了条目

    management.endpoints.web.exposure.include=*
    

    在我的

    application.properties
    

    文件并且它起作用了。

    亲切的问候, 亚历克斯

    【讨论】:

      猜你喜欢
      • 2018-02-14
      • 2017-09-08
      • 2018-02-16
      • 2017-02-20
      • 1970-01-01
      • 2017-07-29
      • 2017-07-06
      • 2017-12-22
      • 2018-12-03
      相关资源
      最近更新 更多