Spring Boot 2.0 内嵌 Tomcat 定制 : WebServerFactoryCustomizer

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 {

@Override
public void customize(ConfigurableServletWebServerFactory server) {
    server.setPort(9000);
}

}

https://stackoverflow.com/questions/43571505/how-to-find-the-interface-embeddedservletcontainercustomizer-in-spring-boot-2-0

你可能感兴趣的:(Spring Boot 2.0 内嵌 Tomcat 定制 : WebServerFactoryCustomizer)