如何统计Spring Boot在Spring测试中加载的次数?

Mic*_*hal 4 java testing spring integration-testing spring-boot

我有一个带有 Spring Boot 测试的应用程序,我可以强制执行 Spring Boot 加载的次数吗?因此,如果有人要加载另一个弹簧靴,我会发出警告。

mic*_*ldo 6

这个问题有点笼统,我的回答可能不完全是我想要的。

logging.level.org.springframework.test.context.cache: debug 可以监控加载了多少个上下文,例如该项目使用 7 个上下文:

Spring测试ApplicationContext缓存统计:[DefaultContextCache@3655a68c size = 7, maxSize = 32,parentContextCount = 0, hitCount = 1780, missCount = 7]