【发布时间】:2019-11-20 00:28:12
【问题描述】:
这是我所拥有的:
@RunWith(SpringRunner::class)
@ActiveProfiles("unit-test")
@WithUserDetails
@WebMvcTest(MyController::class)
class MyControllerTest {
@MockBean
lateinit var service: MyService
@Autowired
lateinit var mvc: MockMvc
但我不断收到类似以下的异常:
org.springframework.beans.factory.NoSuchBeanDefinitionException: No qualifying bean of type
并且每次我添加一个依赖,比如通过:
@MockBean
lateinit var anotherBean: AnotherBean
另一个丢失的 bean 被抛出(有点没完没了)。
在 Kotlin 中是否有适当的解决方案?
【问题讨论】:
标签: spring spring-boot testing kotlin