springboot 启动tomcat流程
2019-10-21 本文已影响0人
zh_89
springboot-tomcat
注意第10步初始化嵌入式Tomcat
@Override
public WebServergetWebServer(ServletContextInitializer... initializers) {
Tomcat tomcat =new Tomcat();
File baseDir =(this.baseDirectory !=null) ?this.baseDirectory : createTempDir("tomcat");
tomcat.setBaseDir(baseDir.getAbsolutePath());
Connector connector =new Connector(this.protocol);
tomcat.getService().addConnector(connector);
customizeConnector(connector);
tomcat.setConnector(connector);
tomcat.getHost().setAutoDeploy(false);
configureEngine(tomcat.getEngine());
for (Connector additionalConnector :this.additionalTomcatConnectors) {
tomcat.getService().addConnector(additionalConnector);
}
prepareContext(tomcat.getHost(), initializers);
return getTomcatWebServer(tomcat);
}