Thrown by a method invocation on a proxy instance if its invocation handler’s invoke method throws a checked exception (a Throwable that is not assignable to RuntimeException or Error) that is not assignable to any of the exception types declared in the throws clause of the method that was invoked on the proxy instance and dispatched to the invocation handler.
An UndeclaredThrowableException instance contains the undeclared checked exception that was thrown by the invocation handler, and it can be retrieved with the getUndeclaredThrowable() method. UndeclaredThrowableException extends RuntimeException, so it is an unchecked exception that wraps a checked exception.
As of release 1.4, this exception has been retrofitted to conform to the general purpose exception-chaining mechanism. The “undeclared checked exception that was thrown by the invocation handler” that may be provided at construction time and accessed via the getUndeclaredThrowable() method is now known as the cause, and may be accessed via the Throwable.getCause() method, as well as the aforementioned “legacy method.”
翻译下:
抛出一个方法调用代理实例的调用处理程序的调用方法抛出一个检查异常(Throwable,不分配RuntimeException或错误),不分配任何的异常类型中声明抛出条款的代理实例上调用方法,并分派到调用处理程序。
UndeclaredThrowableException实例包含调用处理稿卖程序抛出的未声明的检查异常,可以使用getUndeclaredThrowable()方法检索该异常。UndeclaredThrowableException扩展了RuntimeException,因此它是一个未检查的异常,它包装了一个已检查的州敬散异常。
从版本1.4开始,这个异常已经进行了修改,以符合通用异常链接机制。“调用处理程序抛出的未声明的检查异常”可以在构建时提供,并通过getUndeclaredThrowable()方法访问,现在称为原因,可以通过Throwable.getCause()方法以及前面提到的“遗留方法”访问。
查看下JDK的java doc:
JDK的java doc是这么解释UndeclaredThrowableException的: 如果册氏代理实例的调用处理程序的 invoke 方法抛出一个经过检查的异常(不可分配给 RuntimeException 或 Error 的 Throwable),且该异常不可分配给该方法的throws子局声明的任何异常类,则由代理实例上的方法调用抛出此异常。
下面上swagger测试的结果
在看下IDEA中反馈回给我们的信息
最后检查是
XML文件中的<query id = "delete">里面的标签与mapper中的不符合,导致程序运行时,无法正确找到对应的SQL语句,导致出现的异常
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)