4
스프링 부트 1.4.3.RELEASE를 사용 중이며 테스트를 실행할 때 일부 구성 요소가 검사에서 제외됩니다. 필터에도 불구하고스프링 부트 테스트 컨텍스트에서 스프링 ComponentScan excludeFilters 주석이 작동하지 않습니다.
@RunWith(SpringRunner.class)
@SpringBootTest
@ComponentScan(
basePackages = {"com.foobar"},
excludeFilters = @Filter(type = FilterType.ASSIGNABLE_TYPE, classes = {AmazonKinesisRecordChecker.class, MyAmazonCredentials.class}))
public class ApplicationTests {
@Test
public void contextLoads() {
}
}
내가 원하지 않는 구성 요소가로드 테스트를 실행하고 그 클래스가 제대로 작동하기 위해 AWS 환경을 필요로 봄 부팅이 충돌 할 때 :
2017-01-25 16:02:49.234 ERROR 10514 --- [ main] o.s.boot.SpringApplication : Application startup failed
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'amazonKinesisRecordChecker' defined in file
질문 :는 어떻게 할 수 필터를 작동하게 만드시겠습니까?
@SpringBootTest (classes = <<로드 할 클래스 선택 >>). 문서 : http://docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/context/SpringBootTest.html – Barath
@Barath 클래스를 포함 할 수있는 유일한 방법이 있다는 말인가, 스프링 부트 테스트시 제외시키지 않으시겠습니까? – Javide
아니요, 그렇습니다. WebMvcTest를 사용하여 필터를 제외 할 수 있습니다. Doc : http : //docs.spring.io/spring-boot/docs/current/api/org/springframework/boot/test/autoconfigure/web/servlet /WebMvcTest.html – Barath