문제상황
put request를 진행 중 다음과 같은 오류가 떴다.
java.lang.IllegalArgumentException: Name for argument of type [java.lang.Integer] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.
해결방법
1. compiler옵션에 -parameters 추가
(intellij) 사용 시
File -> settings -> Build, Execution, Deployment → Compiler → Java Compiler 에서 Additional command line parameters에 다음 항목 추가
- parameters
프로젝트 폴더 중 out 폴더를 삭제하고 다시 실행(out 폴더를 삭제해야 다시 컴파일 된다고 함.)
2. 파라미터 이름을 명확하게 명시
@PutMapping("/{postId}")
public void updatePost(@PathVariable("postId") Integer postId, @RequestBody Post post){
postService.update(postId, post);
}
@PathVariable에 전달하고자 하는 파라미터 이름을 지정해준다.
참고:
'Web Programming > Spring' 카테고리의 다른 글
Spring Security Architecture (0) | 2024.12.28 |
---|---|
Spring Data JPA (0) | 2024.12.17 |
Spring 학습 정리 (0) | 2024.12.13 |
DispatcherServlet의 위치는? (0) | 2024.12.08 |
STS Spring Boot application can't resolve the org.springframework.boot package 오류 (0) | 2022.06.02 |