2017-12-07 5 views
2

私はSpringブートアプリケーションバージョン1.5.xを使用しています。org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactoryを使用しています。これはSpringブート2に移行しようとしていますが、アプリケーションはコンパイルされません。 。コンパイラが発行する以下のエラー:TomcatEmbeddedServletContainerFactoryがSpringブート2にありません

error: package org.springframework.boot.context.embedded.tomcat 

答えて

5

クラスは、詳細情報の確認のためにorg.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory で取り外して交換されました:あなたは次のコードで置き換えることができます春のブート2.0.0.RELEASEでSpring boot M1 Release Notes

0

::

@Bean 
    public 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; 
    } 
関連する問題