2019/09/18 - [일이야기/Spring] - Tomcat 구동시 ErrorPageFilter 에러 처리
Tomcat 구동시 ErrorPageFilter 에러 처리
기본적으로 Spring boot에서는 에러를 처리하는 filter가 자동으로 동작한다. 하지만 프로젝트에 따라 Application내에서 에러 핸들링을 달리해야 하는데 Filter에서 선처리하고 아래와 같은 에러 로그를 출력한다..
naning9.tistory.com
이전 글에서 ErrorPageFilter를 disabled하고 Application 내에서 에러페이지를 분기하려고
GlobalErrorController를 만들었는데 아래와 같은 에러가 발생했다.
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 'basicErrorController' method public org.springframework.http.ResponseEntity<java.util.Map<java.lang.String, java.lang.Object>> org.springframework.boot.autoconfigure.web.servlet.error.BasicErrorController.error(javax.servlet.http.HttpServletRequest) to { /error}: There is already 'globalErrorController' bean method
내용을 보면 어쩌구 저쩌구....BasicErrorController.error 에 /error 라는 경로가 이미 있다라고 하네..
BasicErrorController를 사용하지 못하도록 처리해 보자.
Java Config
@Configuration
@EnableAutoConfiguration(exclude = ErrorMvcAutoConfiguration.class)
public class ErrorConfiguration {
....
}
또는
Application.yml
spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.web.servlet.error.ErrorMvcAutoConfiguration
'일이야기 > Spring' 카테고리의 다른 글
생성자 주입에 대하여... (0) | 2022.05.17 |
---|---|
mybatis에서 NumberformatException 처리 (0) | 2020.07.01 |
Tomcat 구동시 ErrorPageFilter 에러 처리 (0) | 2019.09.18 |
댓글