本文介绍了“找不到合适的构造函数”使用Jersey 2从我的资源类中提取界面时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我怎样才能让Jersey了解它应该使用具体的类而不是资源的接口?
How can I make Jersey understand that it should use a concrete class instead of the interface for a resource?
我有一个带有<$ c $的工作应用程序c>状态资源。然后我提取了一个接口 IStatus
,并在那里移动了所有JAX-RS注释。现在,我得到:
I had a working app with a Status
resource. Then I extracted an interface IStatus
, and moved all JAX-RS annotations there. Now, I get:
org.glassfish.hk2.api.MultiException A MultiException has 1 exceptions. They are:1. java.lang.NoSuchMethodException: Could not find a suitable constructor in resource.IStatus class
我知道这个与RestEasy合作。是否有任何方法可以使它与泽西岛一起使用?
I know that this works with RestEasy. Is there any way of making it work with Jersey?
推荐答案
把班级等级 @Path
关于实现而不是接口。泽西岛试图实例化界面,但它不能。
Put the class level @Path
on the implementation instead of the interface. Jersey is trying to instantiate the interface, which it can't.
这篇关于“找不到合适的构造函数”使用Jersey 2从我的资源类中提取界面时的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!