Embedded ServletContainer Factory 를 찾 을 수 없 습 니까?

spring boot 에서 https 프로 토 콜 을 사용 할 때 구덩이 에 도 착 했 을 때 Embedded ServletContainer Factory 를 찾 을 수 없 었 습 니 다.그 전에 jar 가방 의 버 전이 낮은 줄 알 았 는데 springboot 2.X 인 것 을 발견 하고 쓰기 가 바 뀌 었 습 니 다.
다음 과 같다.
   //             
    //    http     ,   application     http.port=      80
    @Value("${http.port}")
    Integer httpPort;

    //     https    443
    @Value("${server.port}")
    Integer httpsPort;

    // springboot2   
    @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(httpPort);
        connector.setSecure(false);
        //   http         https    
        connector.setRedirectPort(httpsPort);
        return connector;
    }

좋은 웹페이지 즐겨찾기