简体   繁体   English

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

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

I have a custom WebServerFactoryCustomizer but its not available for management port.我有一个自定义的WebServerFactoryCustomizer但它不适用于管理端口。 What's the best way to make the customization available to server on management port?使自定义可用于管理端口上的服务器的最佳方法是什么? The regular server is on port =8080 and management server is on port = 8082.常规服务器在端口 = 8080 上,管理服务器在端口 = 8082 上。

I tried playing around with ServletManagementWebServerFactoryCustomizer but it didn't work.我尝试使用ServletManagementWebServerFactoryCustomizer但它没有用。 Any pointers will be appreciated.任何指针将不胜感激。

here is the customizer (to disable TRACE for Undertow)这是定制器(为 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())))
  );
 }
}

A sample reproducible service is at https://github.com/ranarula/WebServerCustomizer示例可重现服务位于https://github.com/ranarula/WebServerCustomizer

Indeed I feel lack of information regarding this topic as well but I was able to get it working by following the documentation Adding custom endpoints事实上,我也觉得缺乏关于这个主题的信息,但我能够按照文档添加自定义端点来让它工作

what you can do is just put the customizer in spring.factories你能做的就是把定制器放在spring.factories 中

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

javadocs of this class might be helpful as well ManagementContextConfiguration此类的 javadocs 也可能有帮助ManagementContextConfiguration

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

相关问题 Spring Javers 启动定制器 - Spring Boot Customizer for Javers 如何在 Spring Boot 的不同端口上注册 servlet? - How to register servlet on a different port in spring boot? Spring Boot 2.0 Web应用程序将不会启动嵌入式Servlet容器 - Spring Boot 2.0 web app wont start embedded servlet container Spring 引导:无法启动嵌入式 Tomcat servlet 容器 - Spring boot: Unable to start embedded Tomcat servlet container 设置管理端口时无法使用Spring Boot的执行器 - Spring boot's actuator unavailable when set management port 如何禁用 Spring Boot 应用程序管理端口的安全性? - How to disable security on management port for Spring Boot app? 无法在 Spring 引导应用程序中访问新的管理服务器端口 - Cannot Access new Management Server Port in Spring Boot Application 具有嵌入式tomcat的Spring Boot在端口上运行,但无法正常工作 - Spring boot with embedded tomcat runs on a port but its won't work 如何使用Spring Boot应用程序更改嵌入式tomcat连接器端口 - How to change embedded tomcat connector port using spring boot application Spring 当使用“management.server.port”属性而不是弃用的“management.port”时,启动 MockMvc 测试为执行器端点提供 404 - Spring Boot MockMvc test giving 404 for actuator endpoint when using the "management.server.port" property instead of the deprecated "management.port"
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM