728x90
나의 오류 내용
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'org.springframework.security.config.annotation.web.configuration.WebSecurityConfiguration': Injection of autowired dependencies failed
...
Caused by: java.lang.RuntimeException: Could not postProcess org.springframework.security.config.annotation.web.builders.WebSecurity@443d94ae of type class org.springframework.security.config.annotation.web.builders.WebSecurity
...
Caused by: org.springframework.beans.factory.BeanCreationException: 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]: Ambiguous mapping. Cannot map 'reservationController' method
com.zb.deuggeun.reserve.controller.ReservationController#cancel(Long)
...
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]: Ambiguous mapping. Cannot map 'reservationController' method
com.zb.deuggeun.reserve.controller.ReservationController#cancel(Long)
to {PUT [/reservation/{reservationId}/complete]}: There is already 'reserveController' bean method
com.zb.deuggeun.reserve.controller.ReserveController#complete(Long) mapped.
처음에 젤 위쪽만 보고 security문제인가? 했었는데 아래쪽을 보고는 컨트롤러에서 문제가 있었던 것을 알 수 있었다.
해결
As-is
@PutMapping("/{reservationId}/complete")
public Dto complete() {}
@PutMapping("/{reservationId}/complete")
public Dto cancel() {}
코드를 확인해본 결과 mapping을 중복되게 작성한 것이다.
To-be
@PutMapping("/{id}/complete")
public Dto complete() {}
@PutMapping("/{id}/cancel")
public Dto cancel() {}
중복이 안되게 수정을 해주어서 해결했다.
728x90
'spring > spring' 카테고리의 다른 글
[Spring][RabbitMQ][Exception] Message로 인터페이스 사용하기 (0) | 2024.04.29 |
---|---|
[Spring][RabbitMQ] 설정하고 실행해보기 (0) | 2024.04.22 |
[Spring][스프링 부트 핵심 가이드] 스프링 시큐리티: 서비스의 인증과 권한 부여 (0) | 2024.03.13 |
[Spring][스프링 부트 핵심 가이드] 액추에이터 활용하기 (0) | 2024.03.06 |
[Spring][스프링 부트 핵심 가이드] 서버 간 통신 (0) | 2024.03.05 |