JavaSpring引导执行器端点。enabled=false端点。健康启用=真
我正在使用执行器启用弹簧靴健康检查。因为我们的应用程序依赖于Spring 1.5.21,所以我必须使用执行器1.5.21版本。我在它们的online documentation上读到一些配置,显示您可以应用以下内容,只允许暴露“/health”端点
By default, all endpoints except for shutdown are enabled. If you prefer to specifically “opt-in” endpoint enablement you can use the endpoints.enabled property. For example, the following will disable all endpoints except for info:
endpoints.enabled=false
endpoints.info.enabled=true
因为我需要禁用除“/health”端点之外的所有端点,所以我在应用程序中配置了它。属性文件如下所示。然而,这对我不起作用
endpoints.enabled=false
endpoints.health.enabled=true
结果如下:
http://localhost:8080/health
{"message":"This endpoint is disabled"}
环境:
Spring boot: 1.5.21 release
JDK: 1.8
Application: web application
有什么想法吗?提前谢谢
更新:
在我使用相同的spring boot 1.5.21启动一个新项目之后。释放,下面的设置工作
endpoints.enabled=false
endpoints.health.enabled=true
2020-03-29 19:29:15.541 INFO 9796 --- [ restartedMain] o.s.b.a.e.mvc.EndpointHandlerMapping : Mapped "{[/health || /health.json],methods=[GET],produces=[application/vnd.spring-boot.actuator.v1+json || application/json]}" onto public java.lang.Object org.springframework.boot.actuate.endpoint.mvc.HealthMvcEndpoint.invoke(javax.servlet.http.HttpServletRequest,java.security.Principal)
于3月30日更新:
然而,当我使用SDL Tridion 8.5时,它停止了工作。有什么想法吗
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common-api</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-common</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa</groupId>
<artifactId>dxa-tridion-provider</artifactId>
<version>${dxaversion}</version>
</dependency>
<dependency>
<groupId>com.sdl.dxa.modules</groupId>
<artifactId>dxa-module-core</artifactId>
<version>${dxaversion}</version>
</dependency>
endpoints.enabled=false
endpoints.health.enabled=true
结果:
http://localhost:8080/health
{"message":"This endpoint is disabled"}
# 1 楼答案
不需要使用禁用。仅使用以下属性: