[英]Spring Boot Actuator Endpoint Override
I have been prototyping with Spring boot where I added dependency on spring-boot-starter-actuator
and spring-boot-starter-data-rest
and named my testing REST endpoint to /info
. 我一直在使用Spring启动进行原型设计,其中我添加了对
spring-boot-starter-actuator
和spring-boot-starter-data-rest
,并将我的测试REST端点命名为/info
。 Application ran without any errors however my endpoint couldn't be called and app returned 404 all the time. 应用程序运行没有任何错误,但我的端点无法被调用,应用程序一直返回404。
After some time I found out that actuator project contains SAME endpoint /info
and basically overrides my custom RESTful endpoint since I didn't name it. 一段时间后,我发现执行器项目包含SAME端点
/info
并且基本上覆盖了我的自定义RESTful端点,因为我没有给它命名。
My question is: Is there any way how I can prevent such behavior in general (meaning bean clashing by mistake)? 我的问题是:有什么方法可以防止这种行为(意思是错误的豆子冲突)? Or at least get WARN message when this is happening.
或者至少在发生这种情况时会收到WARN消息。
Thanks in advance for your answers 提前感谢您的回答
You can disable /info
actuator endpoint by using the following property; 您可以使用以下属性禁用
/info
执行器端点;
management.endpoint.info.enabled=false
Actually all can be disabled, or you can enable only certain ones, if you check the source link I've provided below; 实际上,如果您检查我在下面提供的源链接,则可以禁用所有功能,或者只启用某些功能。
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.
如果您希望专门“选择加入”端点启用,则可以使用endpoints.enabled属性。
For logging of this behaviour, while deploying you can see the endpoints and corresponding beans, you can deduce from this log I guess. 要记录此行为,在部署时您可以看到端点和相应的bean,您可以从此日志中推断出我猜。 But better not to use same endpoint with actuator while they are enabled.
但最好不要在启用时使用相同的端点和执行器。
Yes, there is a chance to disable particular classes by @EnableAutoconfiguration
with a parameter exclude=
where you can specify classname or whole package by using {} brackets 是的,有可能通过
@EnableAutoconfiguration
使用参数exclude=
禁用特定类,您可以使用{}括号指定类名或整个包
Example: 例:
@EnableAutoConfiguration(exclude = {MyClassName.class}
@EnableAutoConfiguration(exclude = {MyClassName.class, MyClassName2.class})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.