定制Servlet容器--xxxCustomizer
作者:互联网
2、定制Servlet容器
- 实现 WebServerFactoryCustomizer<ConfigurableServletWebServerFactory>
- 把配置文件的值和
ServletWebServerFactory 进行绑定
- 修改配置文件 server.xxx
- 直接自定义 ConfigurableServletWebServerFactory
xxxxxCustomizer:定制化器,可以改变xxxx的默认规则
import org.springframework.boot.web.server.WebServerFactoryCustomizer; import org.springframework.boot.web.servlet.server.ConfigurableServletWebServerFactory; import org.springframework.stereotype.Component; @Component public class CustomizationBean implements WebServerFactoryCustomizer<ConfigurableServletWebServerFactory> { @Override public void customize(ConfigurableServletWebServerFactory server) { server.setPort(9000); } }
搜一下又有很多xxxFactoryCustomizer
然后实现接口 WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> 进入ConfigurableJettyWebServerFactory
又继承了ConfigurableWebServerFactory 进入后
这个就是默认的实现。
自己实现
public class jettyWebServerFactoryCustomizer implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory>{
然后重写customize 方法
}
public class jettywebserverfactorycustomizer implements WebServerFactoryCustomizer<ConfigurableJettyWebServerFactory> { @Override public void customize(ConfigurableJettyWebServerFactory factory) { factory.setPort(80); } }
标签:--,class,server,customize,WebServerFactoryCustomizer,import,xxxCustomizer,Servle 来源: https://www.cnblogs.com/dzs894330350/p/16695210.html