@WebMvcTest로 컨트롤러 테스트를 짜려고 보니!
@WebMvcTest(DiaryController.class)
class DiaryControllerTest {
@MockBean
private DiaryService diaryService;
@Autowired
private MockMvc mockMvc;
@Autowired
private ObjectMapper objectMapper;
//...
could not autowire. no beans of 'mockmvc' type found.
라는 에러가 떴다. MockMvc랑 ObjectMapper 둘 다 빨간줄이 뜨는데 실행은 잘 된다.
여러가지 시도를 해보았지만 해결이 안 되었다..
뭐가 문제일까?
What versions of Spring Boot and IntelliJ are you using? If you are using Spring Boot 2.7, you need IntelliJ 2022.1.3 or later. See youtrack.jetbrains.com/issue/IDEA-289633 for details. –
- Andy Wilkinson
라는 글을 보게되었다.
스프링 부트 2.7을 사용하는 경우 IntelliJ 2022.1.3 이상이 필요하다고 합니다.
최신버전으로 업데이트하니까 해결되었다.
일단 실행은 문제없이 된다면.. 문제는 IDE에 있는걸로..
댓글