首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Spring boot执行器endpoints.enabled=false endpoints.health.enabled=true

Spring boot执行器endpoints.enabled=false endpoints.health.enabled=true
EN

Stack Overflow用户
提问于 2020-03-29 06:41:11
回答 1查看 1.3K关注 0票数 0

我正在使用执行器启用弹簧启动健康检查。由于我们的应用程序依赖于Spring 1.5.21,所以我必须使用actuator 1.5.21版本。我在他们的online documentation上读到了一些配置,显示您可以将以下内容应用于仅允许"/health“端点公开。

代码语言:javascript
复制
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“端点之外的所有端点,所以我在application.properties文件中对其进行了配置,如下所示。然而,它对我并不起作用。

代码语言:javascript
复制
endpoints.enabled=false
endpoints.health.enabled=true

结果如下:

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

{"message":"This endpoint is disabled"}

环境:

代码语言:javascript
复制
Spring boot: 1.5.21 release
JDK: 1.8
Application: web application

对此有什么想法吗?提前感谢!

更新:

在我使用相同的spring boot 1.5.21.RELEASE启动了一个新项目后,下面的设置起作用了。

代码语言:javascript
复制
endpoints.enabled=false
endpoints.health.enabled=true
代码语言:javascript
复制
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一起使用时,它停止了工作。有什么想法吗?

代码语言:javascript
复制
        <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>
代码语言:javascript
复制
endpoints.enabled=false
endpoints.health.enabled=true

结果:

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

{"message":"This endpoint is disabled"}
EN

回答 1

Stack Overflow用户

发布于 2020-03-29 12:07:56

不需要使用禁用。仅使用以下属性:

代码语言:javascript
复制
management.endpoints.web.exposure.include='health'
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/60907898

复制
相关文章

相似问题

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