Controller 경로 설정 에러

SoDEV·2025년 7월 3일

스프링 부트

목록 보기
16/18

에러1

Caused by: org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.security.web.SecurityFilterChain]: Factory method 'filterChain' threw exception with message: Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invalid mapping on handler class [com.example.petstargram.controller.ArticleController]: public org.springframework.http.ResponseEntity com.example.petstargram.controller.ArticleController.updateComment(long,com.example.petstargram.dto.UpdateCommentDto)
Caused by: org.springframework.util.PlaceholderResolutionException: Could not resolve placeholder 'commentId' in value "/api/comments/${commentId}"

에러 요약

  1. Failed to instantiate ...Error creating bean with name 'mvcHandlerMappingIntrospector' defined in class path resource
    - bean을 생성하는 데에 실패함
  2. Invalid mapping on handler class [com.example.petstargram.controller.ArticleController]: public org.springframework.http.ResponseEntity com.example.petstargram.controller.ArticleController.updateComment(long,com.example.petstargram.dto.UpdateCommentDto)
    • 유효하지 않은 mapping이 ArticleController에서 발생하였다.

ArticleController을 살펴보았다.
기존 코드
@PutMapping("/api/articles/${commentId}")

-> 경로가 잘못 설정되었다.
경로를 제대로 보자! 특수문자가 들어가서 그랬다..😥
/api/comments/${commentId} ->/api/comments/{commentId}변경하니 컴파일이 제대로 되었다!😊

profile
비가 와도 눈이 와도 파도를 향해서! 🌊🐢

0개의 댓글