Home > Java > javaTutorial > body text

Spring boot 1.5.4 web container customization (modification of port number, etc.)

巴扎黑
Release: 2017-06-26 11:35:23
Original
1544 people have browsed it

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;
    }
}
Copy after login

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
Copy after login

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!

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template