Grails JAX-RS 在 src/groovy 中调用 class 给出错误消息:没有方法签名:适用于参数类型

Grails JAX-RS Calling a class in src/groovy giving error - Message: No signature of method: is applicable for argument types

在使用 jaxrs 插件开发其余 api 时,我需要创建一些我在 "src/groovy" 中创建的通用 class。下面是 class

class ValidateToken {
    String validate(String token){
        println(token)  
        return "test"
    }
    //...

在资源文件 (jaxrs) 中,这就是我正在做的事情

def instance=ValidateToken.validate("test")

这会在运行时引发错误

The RuntimeException could not be mapped to a response, re- throwing to the HTTP container
Message: No signature of method: static com.dogmasystems.touroperatorportal.Vali
dateToken.validate() is applicable for argument types: () values: []
Possible solutions: validate(java.lang.String), wait()

我不明白为什么会这样?虽然我发送的是字符串值,但它是作为列表发送的。此外,如果将该方法复制到同一资源文件,则它可以正常工作并将传递的参数视为字符串。

另外请让我知道在哪里保留通用 classes/code ,它将在不同的 Jax-RS 资源中使用。

谢谢。

要么使用 new ValidateToken.validate(...,要么使用 validate 方法 static。这实际上是错误说明的内容:

No signature of method: static ....ValidateToken.validate() is applicable for argument types: () values: []`