2012-12-20 39 views
1

我有它的方法看起来像球衣Web服务方法无法识别为有效的资源方法

@GET 
@Produces(MediaType.TEXT_PLAIN) 
public String getString(@QueryParam("path") path) { 
    return "got the string " + path 
} 

当我运行此我得到一个错误信息

SEVERE: Missing dependency for method public java.lang.String com.example.getString(java.lang.Object) at parameter at index 0 
    SEVERE: Method, public java.lang.String com.example.getString(java.lang.Object), annotated with GET of resource, class com.example.MyServiceClass, is not recognized as valid resource method. 

这是什么错误消息的Web服务意思?如果我没有参数运行服务,那么它就可以工作。

+0

你有'@ Path'注释吗? – Srinivas

+0

我在课堂上有'@ Path'作为一个整体。如果服务中只有一个“@ GET”方法,我是否也需要使用单个方法? –

+0

你能说出你使用的@Path是什么吗?确保@Path(“/ url/{path}”)是这种形式。 – Srinivas

回答

2

回答我的问题...

我使用Groovy和我忘了@QueryParam的类型。这似乎是需要的。

+1

它甚至编译? – Srinivas

+1

是的,这是有效的groovy代码 –