其他分享
首页 > 其他分享> > 定制Servlet容器--xxxCustomizer

定制Servlet容器--xxxCustomizer

作者:互联网

2、定制Servlet容器

 

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