【问题标题】:Grails JAX-RS Calling a class in src/groovy giving error - Message: No signature of method: is applicable for argument typesGrails JAX-RS 在 src/groovy 中调用类给出错误 - 消息:没有方法签名:适用于参数类型
【发布时间】:2015-06-16 19:39:29
【问题描述】:

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

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()

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

另外请让我知道将用于不同 Jax-RS 资源的通用类/代码保存在哪里。

谢谢。

【问题讨论】:

    标签: grails groovy jax-rs


    【解决方案1】:

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

    方法没有签名:static ....ValidateToken.validate() 适用于参数类型:() 值:[]`

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-09-28
      • 1970-01-01
      • 2021-11-02
      • 1970-01-01
      • 2018-12-19
      • 1970-01-01
      相关资源
      最近更新 更多