4
私はSpringブート1.4.3.RELEASEを使用しており、テストの実行中に一部のコンポーネントをスキャンから除外したい。フィルターにもかかわらずSpringのComponentScan excludeFiltersアノテーションがSpringブートテストコンテキストで機能しない
@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