【发布时间】:2014-10-22 09:58:47
【问题描述】:
我有一个要在组件扫描时排除的类。我正在使用下面的代码来做到这一点,但这似乎不起作用,尽管一切似乎都是正确的
@ComponentScan(basePackages = { "common", "adapter", "admin"}, excludeFilters = { @ComponentScan.Filter(type = FilterType.ASSIGNABLE_TYPE, value = ServiceImpl.class) })
实际上,我希望在我的其余 api 逻辑中使用实现“Service”接口的“ServiceImpl”类,并且在对 api 进行集成测试时,我想排除这个实现并加载模拟的实现。但这似乎并没有发生,因为即使在使用上述内容后我也收到以下错误
No qualifying bean of type [admin.Service] is defined: expected single matching bean but found 2: ServiceMockImpl,ServiceImpl
我在这方面花了太多时间,但没有任何效果。
感谢任何帮助。
【问题讨论】:
标签: java spring unit-testing dependency-injection