修改启动类文件,重配置一下tomcat
@Configuration public class TomcatConfig { @Value("${server.http.port}") private int httpPort; @Bean public ServletWebServerFactory servletContainer() { TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); tomcat.addAdditionalTomcatConnectors(createStandardConnector()); // 添加http return tomcat; } private Connector createStandardConnector() { Connector connector = new Connector(TomcatServletWebServerFactory.DEFAULT_PROTOCOL); connector.setPort(httpPort); return connector; } }
原文:https://www.cnblogs.com/xxcbz/p/15269245.html