@WebMvcTest not running due to missing dependency

后端 未结 1 1480
迷失自我
迷失自我 2021-01-17 03:05

I want to test my controller by using @WebMvcTest. I @MockBean the dependencies of the controller but when running the test, it fails to start. The

1条回答
  •  小蘑菇
    小蘑菇 (楼主)
    2021-01-17 03:07

    You must move all area-specific configuration, like @ComponentScan and @EnableMongoRepositories, to a separate @Configuration file. It's important not to litter the application’s main class with configuration settings that are specific to a particular area of its functionality.

    More information: https://docs.spring.io/spring-boot/docs/2.0.3.RELEASE/reference/htmlsingle/#boot-features-testing-spring-boot-applications-testing-user-configuration

    0 讨论(0)
提交回复
热议问题