|
@@ -1,5 +1,9 @@
|
|
|
package com.huimv.admin;
|
|
|
|
|
|
+import org.apache.catalina.Context;
|
|
|
+import org.apache.catalina.connector.Connector;
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityCollection;
|
|
|
+import org.apache.tomcat.util.descriptor.web.SecurityConstraint;
|
|
|
import org.apache.tomcat.util.http.LegacyCookieProcessor;
|
|
|
import org.mybatis.spring.annotation.MapperScan;
|
|
|
import org.springframework.boot.SpringApplication;
|
|
@@ -30,5 +34,34 @@ public class HuimvAdminApplication {
|
|
|
context.setCookieProcessor(new LegacyCookieProcessor());
|
|
|
});
|
|
|
}
|
|
|
+ @Bean
|
|
|
+ public TomcatServletWebServerFactory servletContainer() {
|
|
|
+ TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {
|
|
|
+ @Override
|
|
|
+ protected void postProcessContext(Context context) {
|
|
|
+ SecurityConstraint constraint = new SecurityConstraint();
|
|
|
+ constraint.setUserConstraint("CONFIDENTIAL");
|
|
|
+ SecurityCollection collection = new SecurityCollection();
|
|
|
+ collection.addPattern("/*");
|
|
|
+ constraint.addCollection(collection);
|
|
|
+ context.addConstraint(constraint);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ tomcat.addAdditionalTomcatConnectors(httpConnector());
|
|
|
+ return tomcat;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Bean
|
|
|
+ public Connector httpConnector() {
|
|
|
+ Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");
|
|
|
+ connector.setScheme("http");
|
|
|
+ //Connector监听的http的默认端口号
|
|
|
+ connector.setPort(8010);
|
|
|
+ connector.setSecure(false);
|
|
|
+ //监听到http的端口号后转向到的https的端口号,也就是项目配置的port
|
|
|
+ connector.setRedirectPort(8011);
|
|
|
+ return connector;
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|