小编Vij*_*jay的帖子

创建类路径资源中定义的名为“handlerExceptionResolver”的 bean 时出错

我有一个简单的项目,我在其中创建了自定义异常处理。有趣的是,当我编译这个项目时,它给了我一个错误。

Error creating bean with name 'handlerExceptionResolver' defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.web.servlet.HandlerExceptionResolver]: Factory method 'handlerExceptionResolver' threw exception; nested exception is java.lang.IllegalStateException: Ambiguous @ExceptionHandler method mapped for [class java.lang.Exception]: {public final org.springframework.http.ResponseEntity com.winwinit.rest.microservices.restfulwebservices.Exception.CustomizedEntityExceptionResponse.handleAllUserException(java.lang.Exception,org.springframework.web.context.request.WebRequest), public final org.springframework.http.ResponseEntity com.winwinit.rest.microservices.restfulwebservices.Exception.CustomizedEntityExceptionResponse.handleAllException(java.lang.Exception,org.springframework.web.context.request.WebRequest)}
    at org.springframework.beans.factory.support.ConstructorResolver.instantiate(ConstructorResolver.java:627) ~[spring-beans-5.1.6.RELEASE.jar:5.1.6.RELEASE]
Run Code Online (Sandbox Code Playgroud)
package com.winwinit.rest.microservices.restfulwebservices.Exception;

import java.util.Date;

import org.omg.CORBA.portable.UnknownException;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.context.request.WebRequest;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;


import com.winwinit.rest.microservices.restfulwebservices.User.UserNotFoundException;

@ControllerAdvice
@RestController
public class …
Run Code Online (Sandbox Code Playgroud)

java spring exception

4
推荐指数
1
解决办法
2万
查看次数

标签 统计

exception ×1

java ×1

spring ×1