弹簧启动执行器不按预期工作



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

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>

非常感谢!

似乎在我使用的Spring Boot版本中,默认情况下没有暴露端点/actuator/info,因为它在早期版本的Spring - Boot中。

为了公开它,我添加了条目
management.endpoints.web.exposure.include=*

在我的

application.properties

文件,它工作了。

亲切的问候,亚历克斯

最新更新