Spring Boot 2中缺少TomcatEmbeddedServletContainerFactory

Spring Boot 2中缺少TomcatEmbeddedServletContainerFactory,第1张

Spring Boot 2中缺少TomcatEmbeddedServletContainerFactory

在Spring boot 2.0.0.RELEASE中,你可以替换为以下代码

@Beanpublic ServletWebServerFactory servletContainer() {    TomcatServletWebServerFactory tomcat = new TomcatServletWebServerFactory() {        @Override        protected void postProcessContext(Context context) { SecurityConstraint securityConstraint = new SecurityConstraint(); securityConstraint.setUserConstraint("CONFIDENTIAL"); SecurityCollection collection = new SecurityCollection(); collection.addPattern("/*"); securityConstraint.addCollection(collection); context.addConstraint(securityConstraint);        }    };    tomcat.addAdditionalTomcatConnectors(redirectConnector());    return tomcat;}private Connector redirectConnector() {    Connector connector = new Connector("org.apache.coyote.http11.Http11NioProtocol");    connector.setScheme("http");    connector.setPort(8080);    connector.setSecure(false);    connector.setRedirectPort(8443);    return connector;}


欢迎分享,转载请注明来源:内存溢出

原文地址: http://outofmemory.cn/zaji/5021857.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-11-15
下一篇 2022-11-15

发表评论

登录后才能评论

评论列表(0条)

保存