Spring boot uses Tomcat as the embedded Web container by default
There are three ways to customize
1.2. The following
@Component Public classCustomizationbeanImplementsembeddedservletcontainercustomizer{/*** Customizing Method One: Realizing Embeddedservletcontainercustomizer *@paramContainer*/@Override Public voidCustomize (Configurableembeddedservletcontainer container) {//Container.setport (9000); } /*** Custom Method II: Inject Embeddedservletcontainerfactory *@return */@Bean Publicembeddedservletcontainerfactory Servletcontainer () {Tomcatembeddedservletcontainerfactory factory=Newtomcatembeddedservletcontainerfactory (); Factory.setport (9001); Factory.setsessiontimeout (10, timeunit.minutes); //higher priority than 404.html pages configured in the/static/error folderFactory.adderrorpages (NewErrorPage (Httpstatus.not_found, "/error/403.html")); returnFactory; }}
3. Configure the configuration file to add the relevant configuration, as follows
#=====================servlet container config==================server.port=8080server.ssl.enabled =falseserver.address=127.0.0.1server.session.persistent=true# 1800 seconds,30 minutesserver.session.timeout=1800server.session.store-dir=/users/hdwang/ Sessiontmp
Third, spring boot Web container customization (port number and other modifications)