首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >spring boot执行器无法按预期工作

spring boot执行器无法按预期工作
EN

Stack Overflow用户
提问于 2021-09-18 11:06:16
回答 1查看 131关注 0票数 0

我开始学习spring boot,我刚刚在我的pom.xml中导入了我的弹簧驱动器。现在,端点

代码语言:javascript
运行
复制
http://localhost:8080/actuator/health

工作正常,并且下面的终结点

代码语言:javascript
运行
复制
http://localhost:8080/actuator/

向我显示以下信息:

代码语言:javascript
运行
复制
{"_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}}}

但是,在文件夹中

代码语言:javascript
运行
复制
src/main/resources

我添加了文件

代码语言:javascript
运行
复制
application.properties

它包含以下属性:

代码语言:javascript
运行
复制
info.app.name=My Super Cool App
info.app.description=A crazy and fun app, yahoo!
info.app.version=1.0.0

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

代码语言:javascript
运行
复制
http://localhost:8080/actuator/info

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

代码语言:javascript
运行
复制
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中找到一个摘录:

代码语言:javascript
运行
复制
<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>

非常感谢!

EN

Stack Overflow用户

发布于 2021-09-18 11:09:44

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

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

代码语言:javascript
运行
复制
management.endpoints.web.exposure.include=*

在我的

代码语言:javascript
运行
复制
application.properties

文件,并且它起作用了。

亲切的问候,亚历克斯

票数 1
EN
查看全部 1 条回答
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/69234068

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档