오늘 작은 sns를 만드는 프로젝트를 진행하던 도중 Failed to load ApplicationContext 오류를 겪었다.
뭔가 DI에 문제가 생긴 느낌이 들어 에러 문구를 읽어봤다.
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'requestMappingHandlerMapping' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Invocation of init method failed; nested exception is java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method
com.example.project_travel_sns.controller.UserController#login(UserLoginRequest)
to {POST [/api/v1/users/join]}: There is already 'userController' bean method
해당 문구를 자세히 읽어보니 POST /api/v1/users/join api가 이미 존재한다고 하여 Controller 클래스로 이동하여 확인해보았다.
역시... api를 추가할려고 빠르게 진행하다보니 url을 변경하지 않아 발생한 문제였다.
종종 오늘과 같은 오류를 겪었지만 며칠 지나면 까먹고 하여 오늘 기록해본다...
아마 Bean으로 등록한 객체 중 문법이 잘못된 경우나, url을 잘못적었거나 entity 설계를 잘못하면 오늘과 같은 문제가 발생한 것 같았다...
다음에 또 발생한다면 기억해 내길.....