相关疑难解决方法(0)

Spring Testing:如何启用bean的自动扫描

例如,现在我必须在每个测试类中完成

@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(loader=AnnotationConfigContextLoader.class)
Run Code Online (Sandbox Code Playgroud)

我想摆脱

 @ContextConfiguration(loader=AnnotationConfigContextLoader.class)
Run Code Online (Sandbox Code Playgroud)

并希望Spring扫描我项目中的所有bean.

我怎样才能做到这一点?

spring unit-testing spring-test

13
推荐指数
3
解决办法
3万
查看次数

为什么使用spring.factories进行Spring Boot自动配置而不是注释?

文件说明:

开发自动配置和使用条件

如果您在开发共享库的公司工作,或者您在开源或商业库中工作,则可能需要开发自己的自动配置.自动配置类可以捆绑在外部jar中,仍然可以通过Spring Boot获取.

如果我有其他所有注释(甚至@AutoConfigureAfter或@AutoConfigureBefore注释),

为什么要将属性文件维护为指向带注释的类?

spring-boot

11
推荐指数
1
解决办法
5903
查看次数

标签 统计

spring ×1

spring-boot ×1

spring-test ×1

unit-testing ×1