繁体   English   中英

Spring Boot 将嵌入式 servlet 定制器复制到管理端口

[英]Spring Boot replicate embedded servlet customizer to management port

我有一个自定义的WebServerFactoryCustomizer但它不适用于管理端口。 使自定义可用于管理端口上的服务器的最佳方法是什么? 常规服务器在端口 = 8080 上,管理服务器在端口 = 8082 上。

我尝试使用ServletManagementWebServerFactoryCustomizer但它没有用。 任何指针将不胜感激。

这是定制器(为 Undertow 禁用 TRACE)

public class UndertowCustomizer implements
  WebServerFactoryCustomizer<ConfigurableUndertowWebServerFactory> {

@Override
public void customize(final ConfigurableUndertowWebServerFactory undertowWebServerFactory) {
  undertowWebServerFactory.addDeploymentInfoCustomizers(deploymentInfo ->
      deploymentInfo.addInitialHandlerChainWrapper(handler ->
          new DisallowedMethodsHandler(handler, HttpString.tryFromString(HttpMethod.TRACE.name())))
  );
 }
}

示例可重现服务位于https://github.com/ranarula/WebServerCustomizer

事实上,我也觉得缺乏关于这个主题的信息,但我能够按照文档添加自定义端点来让它工作

你能做的就是把定制器放在spring.factories 中

org.springframework.boot.actuate.autoconfigure.web.ManagementContextConfiguration=UndertowCustomizer

此类的 javadocs 也可能有帮助ManagementContextConfiguration

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM