spring boot uses tomcat as the embedded web container by default
There are three customization methods
1. 2. As follows
@Componentpublic class CustomizationBean implements EmbeddedServletContainerCustomizer{/** * 定制方法一:实现EmbeddedServletContainerCustomizer * @param container */@Overridepublic void customize(ConfigurableEmbeddedServletContainer container) {//container.setPort(9000); }/** * 定制方法二:注入EmbeddedServletContainerFactory * @return */@Beanpublic EmbeddedServletContainerFactory servletContainer() { TomcatEmbeddedServletContainerFactory factory = new TomcatEmbeddedServletContainerFactory(); factory.setPort(9001); factory.setSessionTimeout(10, TimeUnit.MINUTES);//优先级高于配置在/static/error文件夹里面的404.html页面factory.addErrorPages(new ErrorPage(HttpStatus.NOT_FOUND, "/error/403.html"));return factory; } }
3. Add relevant configurations to the configuration file, as follows
#=====================servlet container config==================server.port=8080server.ssl.enabled=falseserver.address=127.0.0.1server.session.persistent=true#1800 seconds,30 minutes server.session.timeout=1800server.session.store-dir=/Users/hdwang/sessiontmp
The above is the detailed content of Spring boot 1.5.4 web container customization (modification of port number, etc.). For more information, please follow other related articles on the PHP Chinese website!