Spring Boot 2.0 内嵌 Tomcat 定制 : WebServerFactoryCustomizer
在 Spring Boot 1.x 中 ,我们通过 EmbeddedServletContainerCustomizer 接口调优 Tomcat 自定义配置。 在Spring Boot 2.0 中,通过 WebServerFactoryCustomizer 接口定制。
As far as the port is concerned, I'd use the configuration option as already answered.
However, you can still use a customizer, however, the types and location will change in Spring Boot 2.0, see:
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);
}
}
本文介绍了如何在SpringBoot 2.0中使用WebServerFactoryCustomizer接口来定制内嵌Tomcat的配置,包括设置端口等。此方法替代了SpringBoot 1.x中使用的EmbeddedServletContainerCustomizer接口。
578

被折叠的 条评论
为什么被折叠?



