2017-12-07 1 views
2

org.springframework.boot.context.embedded.tomcat.TomcatEmbeddedServletContainerFactory을 사용하는 Spring Boot 응용 프로그램 버전 1.5.x가 있습니다. Spring Boot 2로 마이그레이션하려고 시도하지만 응용 프로그램이 컴파일되지 않습니다. 종속성이 org.springframework.boot:spring-boot-starter-tomcat입니다. . 클래스를 제거하고 더 많은 정보 확인을 위해 org.springframework.boot.web.embedded.tomcat.TomcatServletWebServerFactory 으로 대체되었습니다TomcatEmbeddedServletContainerFactory가 Spring Boot 2에 없습니다.

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

답변

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; 
    }