모듈 테스트 및 일반적인 웹 애플리케이션에서 시작 시간을 줄이기 위해 컴포넌트 스캔을 피하려고합니다.ComponentScan을 사용하지 않고 스프링 부트 웹 애플리케이션을 시작하는 방법
내가 @SpringBootConfiguration @EnableAutoConfiguration
와 @SpringBootApplication
교체, 나는 다음과 같은 오류가 얻을 :
Unable to start EmbeddedWebApplicationContext due to missing EmbeddedServletContainerFactory bean
내가 수동으로 EmbeddedServletContainerFactory
를 어떻게 든 가져올 수 있습니까?
예, 코드가 제 3 자 라이브러리 인 경우에도 코드 (주석이 달린 구성) 내에 구성을 "복제"할 수 있습니다. 실제로 어떤 이유로 든 구성을 대체해야하는 경우에 유용합니다. 내 테스트에서는 구성 요소 스캔 사용과 사용하지 않음 간의 차이가 거의 없습니다. 나는 그것을 피할 것이다. – rdllopes
'org.springframework.boot.autoconfigure.web.EmbeddedServletContainerAutoConfiguration'을 살펴보십시오. 이것은 spring-boot가'EmbeddedServletContainerFactory'를 생성하는 방법입니다. 이유가 무엇인지 알기 원한다면 조건을 디버그 해보는 것이 더 많은 정보없이 테스트에 포함되지 않은 이유를 말할 수는 없지만, 자신 만의 공장을 등록하려면 적절한 'EmbeddedServletContainerFactory 'EmbeddedServletContainerAutoConfiguration'의 bean 설정. – Pieter