본문 바로가기

(Spring boot) error: incompatible types: JsonPathResultMatchers cannot be converted to ResultMatcher 해결방법

2020. 12. 14.

메소드를 테스트 하던 중 다음 과 같은 오류가 발생했다.

 

그리고 코드 상에서

jsonPath 작성한 줄이 빨간색 줄이 들어갔다.

 

 

해결 방법

 

1. import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.jsonPath;

를 직접 작성한다.

 

위 방법으로 해결한 블로거가 존재했다. 하지만 나는 해결할 수 없었다.

 

2. import static org.hamcrest.Matchers.is -> import static org.hamcrest.Matchers.is 로변경한다.

 

is를 사용하기위해 자동으로 import 된 부분이 적절하지 못했기 때문에 발생한 오류였다.

백기선님의 강의 댓글에서 알 수 있었던 내용이다.

 

출처 www.inflearn.com/questions/20818

 

 

댓글