SpringBoot 2.0以上就不再使用EmbeddedServletContainerCustomizer,取而代之的是WebServerFactoryCustomizer,通过它同样可以修改Servlet容器的相关配置
@Bean
public WebServerFactoryCustomizer<ConfigurableWebServerFactory> myWebServerFactoryCustomizer(){
return new WebServerFactoryCustomizer<ConfigurableWebServerFactory>() {
@Override
public void customize(ConfigurableWebServerFactory factory) {
factory.setPort(8083);
}
};
}