Caused by: java.lang.RuntimeException: Could not postProcess org.springframework.security.config.annotation.web.builders.WebSecurity@61d4155b of type class org.springframework.security.config.annotation.web.builders.WebSecurity
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'mvcHandlerMappingIntrospectorRequestTransformer': Cannot resolve reference to bean 'mvcHandlerMappingIntrospector' while setting constructor argument
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 'userController' method
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 'userController' method
Caused by: java.lang.IllegalStateException: Ambiguous mapping. Cannot map 'userController' method
Execution failed for task ':TradingMatchingServiceApplication.main()'.
> Process 'command 'C:\Users\user\.jdks\openjdk-21.0.1\bin\java.exe'' finished with non-zero exit value 1
* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.
> Get more help at https://help.gradle.org.
Deprecated Gradle features were used in this build, making it incompatible with Gradle 9.0.
You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.
For more on this, please refer to https://docs.gradle.org/8.5/userguide/command_line_interface.html#sec:command_line_warnings in the Gradle documentation.
BUILD FAILED in 3s
3 actionable tasks: 2 executed, 1 up-to-date
스프링부트에 JWT source를 넣고 회원가입 컨트롤러를 만들기위해 UserController를 작성 중
Could not postProcess org.springframework.security.config.annotation.web.builders.WebSecurity 에서 에러가 발생했다.
찾아보니 웹에 관련된 어노테이션이나 매핑 중복이 원인이라고 하여 프로젝트내 중복을 찾아보았다.
해결
다른 컨트롤러에 같은 api 경로가 있어 중복으로 인한 에러였다. 중복된 경로를 수정하여 해결하였다.
예))
@GetMapping("/hello") // /hello라는 매핑경로가 다른 컨트롤러에도 존재
public ResponseEntity<String> hello() {
return ResponseEntity.ok("hello");
}