fastcampus-eatgo
fastcampus-eatgo copied to clipboard
18강 가게수정 컴파일러 오류
안녕하세요.
18강 듣던 중 .content
부분에서 에러가 뜹니다.
1. 코드는 아래와 같습니다.
@Test
public void update() throws Exception {
mvc.perform(patch("/restaurants/1004")
.contentType(MediaType.APPLICATION_JSON)
.content("{\"name\":\"Joker Bar\",\"address\":\"Busan\"}"))
.andExpect(status().isOk());
}
2. content 부분에 아래와 같이 오류 내용이 뜹니다.
Cannot resolve method 'content' in 'BodyBuilder'
3. update를 run 하면 아래와 같이 오류 메세지가 뜹니다.
.content("{\"name\":\"Joker Bar\",\"address\":\"Busan\"}"))
^
symbol: method content(String)
location: interface BodyBuilder
1 error
> Task :eatgo-api:compileTestJava FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':eatgo-api:compileTestJava'.
> Compilation failed; see the compiler error output for details.
빌드가 안되는 거 같은데 뭐 때문인지 문제 해결 방법 도움 부탁 드립니다.
감사합니다.
patch
는 MockHttpServletRequestBuilder
를 리턴합니다. 현재는 BodyBuilder
를 리턴하는 상황인데, 다른 패키지를 import
하고 있을 겁니다.
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.patch;
구글링 하느라 3시간 헤맸는데 피드백 해주신 덕에 바로 고쳤어요. 강의 잘 듣고 있습니다. 감사합니다.