簡體   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