I’m new with spring boot. I follow clean architecture with spring boot in this link https://www.baeldung.com/spring-boot-clean-architecture In this tutorial, spring context load bean with bean factory. Then when I want to test API with MockMvc. I write test class follow this:
@SpringBootTest
class ApplicationTests {
@Autowired
private MockMvc mockMvc;
@Test
void contextLoads(){
}
}
But run testcase got error: class org.springframework.web.context.support.GenericWebApplicationContext cannot be cast to class org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext (org.springframework.web.context.support.GenericWebApplicationContext and org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext are in unnamed module of loader ‘app’)
Any can explain this error or config bean in Spring boot test?
1