From 05aebb26d1e2e1fbaebe0119876aa97caea1fef5 Mon Sep 17 00:00:00 2001 From: whycxzp <glperry@163.com> Date: 星期五, 06 九月 2024 09:58:08 +0800 Subject: [PATCH] 更新 --- src/main/java/com/whyc/App.java | 29 +++++++++++++++++++++++++++++ 1 files changed, 29 insertions(+), 0 deletions(-) diff --git a/src/main/java/com/whyc/App.java b/src/main/java/com/whyc/App.java index 215147f..ce41089 100644 --- a/src/main/java/com/whyc/App.java +++ b/src/main/java/com/whyc/App.java @@ -1,9 +1,15 @@ package com.whyc; +import org.apache.catalina.connector.Connector; +import org.springframework.beans.factory.annotation.Value; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.boot.autoconfigure.condition.ConditionalOnProperty; +import org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory; import org.springframework.boot.web.servlet.ServletComponentScan; +import org.springframework.boot.web.servlet.server.ServletWebServerFactory; import org.springframework.cache.annotation.EnableCaching; +import org.springframework.context.annotation.Bean; import org.springframework.web.servlet.config.annotation.EnableWebMvc; import org.springframework.web.servlet.config.annotation.WebMvcConfigurer; import org.springframework.web.servlet.config.annotation.WebMvcConfigurerAdapter; @@ -22,4 +28,27 @@ SpringApplication.run(App.class, args); } + @Value("${http.port}") + private Integer httpPort; + + @Bean + @ConditionalOnProperty(prefix = "spring.profiles",name = "active",havingValue = "prod-ssl") + public ServletWebServerFactory servletContainer() { + TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory(); + // 娣诲姞http + tomcat.addAdditionalTomcatConnectors(createStandardConnector()); + return tomcat; + } + + /** + * 閰嶇疆http + * + * @return connector + */ + private Connector createStandardConnector() { + Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol"); + connector.setPort(httpPort); + return connector; + } + } -- Gitblit v1.9.1