Java 如何禁用/重新启动终结点的授权?

Java 如何禁用/重新启动终结点的授权?,java,spring-boot,spring-security,spring-cloud,application-restart,Java,Spring Boot,Spring Security,Spring Cloud,Application Restart,我尝试在我的web应用程序中实现重启功能 我添加了以下依赖项: compile("org.springframework.boot:spring-boot-starter-actuator") compile("org.springframework.cloud:spring-cloud-starter:1.2.4.RELEASE") 在启动日志中,我发现post/restart已注册 我决定请求此url: 但结果是失败。我知道这个url应该受到保护,但我有自定义的授权/身份验证机制,我无权

我尝试在我的web应用程序中实现重启功能

我添加了以下依赖项:

compile("org.springframework.boot:spring-boot-starter-actuator")
compile("org.springframework.cloud:spring-cloud-starter:1.2.4.RELEASE")
在启动日志中,我发现post/restart已注册

我决定请求此url:

但结果是失败。我知道这个url应该受到保护,但我有自定义的授权/身份验证机制,我无权更改它

有没有办法禁用此url的保护?一个更好的方法是将服务注入控制器并调用。弹簧内部有什么东西可以解决我的问题吗?

试试这个:

endpoints.restart.enabled = true
management.security.enabled=false
试试这个:

endpoints.restart.enabled = true
management.security.enabled=false

原因是spring cloud默认为端点启用了安全性。您需要在属性中禁用管理安全性(因为/restart endpoint是管理的附加端点):

management.security.enabled=false
要将端点从../restart重新映射到/foo/restart,需要添加其他属性:

management.context-path=/foo
要实现自定义端点,只需实现接口端点并重写其方法

要禁用默认重新启动终结点,请执行以下操作:

endpoints.restart.enabled=false

原因是spring cloud默认为端点启用了安全性。您需要在属性中禁用管理安全性(因为/restart endpoint是管理的附加端点):

management.security.enabled=false
要将端点从../restart重新映射到/foo/restart,需要添加其他属性:

management.context-path=/foo
要实现自定义端点,只需实现接口端点并重写其方法

要禁用默认重新启动终结点,请执行以下操作:

endpoints.restart.enabled=false


只需在您的网络配置中禁用它@Derb先生,实际上我在ClassPath中没有spring安全性,那么安全性从何而来呢???org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor#isUserAllowedAccess@HerrDerb,我使用cuetom安全机制。此机制与Spring无关,请在您的网络配置中禁用它@Derb先生,实际上我在ClassPath中没有spring安全性,那么安全性从何而来呢???org.springframework.boot.actuate.endpoint.mvc.MvcEndpointSecurityInterceptor#isUserAllowedAccess@HerrDerb,我使用cuetom安全机制。这个机制与Spring无关,也许你知道如何重新映射URL?我只需要在控制器中执行一些与自定义身份验证相关的附加检查,用正确的答案更新您的答案
endpoints.restart.enabled=true
@AndriyBr。也许您知道如何重新映射URL?我只需要在控制器中执行一些与我的自定义身份验证相关的附加检查,用正确的
endpoints.restart.enabled=true
@AndriyBr更新您的答案。我想为此url注册我自己的控制器。有可能吗?在这种情况下,我发现SpringURL具有更高的优先级。首先,您需要禁用默认/重新启动端点。restart.enabled=false,然后自行实现此/重新启动端点。或者您可以添加自定义端点,要做到这一点,您只需实现接口端点并重写其方法。如果我使用endpoints.restart.enabled=false,然后在控制器中重新启动mvcendpoint.invoke,它会响应“此端点已禁用”我试图自动连接导入org.springframework.cloud.context.restart.RestartEndpoint,但在这种情况下,我看到应用程序inly关闭,而不是upI,我想为这个url注册我自己的控制器。有可能吗?在这种情况下,我发现SpringURL具有更高的优先级。首先,您需要禁用默认/重新启动端点。restart.enabled=false,然后自行实现此/重新启动端点。或者您可以添加自定义端点,要做到这一点,您只需实现接口端点并重写其方法。如果我使用endpoints.restart.enabled=false,然后在控制器中重新启动mvcendpoint.invoke,它会响应“此端点已禁用”我试图自动连接导入org.springframework.cloud.context.restart.RestartEndpoint,但在这种情况下,我发现应用程序通常会关闭,而不是启动