1.修改和Server有關的配置(都在ServerProPerties類中)
server.servlet.context-path=/crud server.port=8081 server.tomcat.uri-encoding=UTF-8
2.編寫嵌入式Servlet容器的定制器
WebServerFactoryCustomizer<ConfigurableWebServerFactory> webServerFactoryCustomizer(){
}

3.注冊Servlet,Filter,Listener
首先自定義servlet

定義好了需要注冊
//注冊三大組件
@Bean
public ServletRegistrationBean myServlet(){
ServletRegistrationBean registrationBean = new ServletRegistrationBean(new Myservlet(),"/myServlet");
return registrationBean;
}


4使用其他Servlet容器
默認Tomcat
支持Jetty(長連接應用【聊天】)
和Undertow(並發性能好但不支持JSP)
