Kau*_*ele 6 spring-boot spring-boot-actuator
我有一个运行的Springboot应用程序,它提供URL http://localhost:8081/topics
并按预期返回JSON响应.
我添加了执行器依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
<scope>test</scope>
</dependency>
但是当我击中http://localhost:8081/health
它时没有给出预期的结果.它说
{
"timestamp": 1497952368055,
"status": 404,
"error": "Not Found",
"message": "No message available",
"path": "/health"
}
Spring启动版本是1.5.4.RELEASE.和Java 1.8我还需要做哪些其他设置?
sam*_*vic 10
在Spring Boot 2.0.0中你必须使用/actuator/health
并在application.properties文件中添加以下行:
management.endpoint.health.show-details=always
Run Code Online (Sandbox Code Playgroud)
执行以下步骤:-
将执行器依赖的范围从 更改test
为compile
而不是使用/health
使用/actuator/health
management.endpoint.health.show-details=always
在application.properties file
。小智 6
添加 Maven 依赖
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
Run Code Online (Sandbox Code Playgroud)
应用程序属性
management.endpoints.web.exposure.include= "*"
包括执行器上的所有端点,或者
management.endpoints.web.exposure.include= health
如果只需要健康端点
在你的依赖中你已经声明了
<scope>test</scope>
Run Code Online (Sandbox Code Playgroud)
代表着
测试
此范围表示该依赖项对于应用程序的正常使用来说不是必需的,并且仅适用于测试编译和执行阶段。
如果您希望它可用于应用程序的正常使用,请将<scope>test</scope>
其删除或更改为<scope>compile</scope>
归档时间: |
|
查看次数: |
7483 次 |
最近记录: |