【发布时间】:2021-10-02 08:38:14
【问题描述】:
我有一个 Spring Boot 集成测试:
@SpringBootTest
@ActiveProfiles("test")
public class ProductServiceIT {
}
当我运行它时,我得到以下异常:
Caused by: org.springframework.beans.factory.UnsatisfiedDependencyException: Error
creating bean with name 'adminPostsController' defined in file
此 AdminPostsController 与此集成测试无关。并且仅因为它位于应用程序上下文中而被调用。 当然我可以在我的测试中将它添加为@MockBean,但这似乎不是最好的解决方案。 有人可以帮助我如何仅为此服务启动应用程序上下文,类似于@WebMvcTest(ProductsController.class),或者给我一些其他解决方案的提示。
【问题讨论】:
-
如果您有任何问题或需要更多信息,请直接询问,不要只是投反对票。这没有帮助
标签: java spring spring-boot