新建一个类 TomcatServerCustomerConfig 实现接口 WebServerFactoryCustomizer
这些就可以同时有http接口和https接口了。基于springbott+tomcat
import org.apache.catalina.connector.Connector;
import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory;
import org.springframework.boot.web.server.WebServerFactoryCustomizer;
import org.springframework.stereotype.Component;
/**
* @Name TomcatServerCustomerConfig
* @Author xiaoLi
* @Date 2023/11/30 星期四 17:20
*/
@Component
public class TomcatServerCustomerConfig implements WebServerFactoryCustomizer<TomcatServletWebServerFactory> {
@Override
public void customize(TomcatServletWebServerFactory factory) {
final Connector httpConn = new Connector("HTTP/1.1");
httpConn.setPort(5678);
factory.addAdditionalTomcatConnectors(httpConn);
}
}
标签:http,端口,springframework,Connector,WebServerFactoryCustomizer,https,import,org
From: https://www.cnblogs.com/xiaolibiji/p/17867872.html