Grails - 方法的签名不适用于参数类型 [英] Grails - No signature of method is applicable for argument types

查看:113
本文介绍了Grails - 方法的签名不适用于参数类型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我从Grails开始(主要使用Eclipse插件),并且一直在阅读Java src文件时遇到问题 - 无论它是bin文件夹中的jar还是src / java文件夹中的Java文件。 p>

我创建了一个如何从我的控制器调用的示例,这是一种Java静态方法,出于某种原因,参数类型存在问题。这是控制器:

  def attempt = {
int counter = 20
int val1 = 1
int val2 = 1
def list = Replicate.create(counter,val1,val2)
render list.size()
}

以下是src / Java文件夹中的Java文件:

  public class Replicate {

public static LinkedList< Pair< Integer,Integer>> create(int count,int val1,int val2){

LinkedList< Pair< Integer,Integer>> list = new LinkedList< Pair< Integer,Integer>>();

for(int i = 0; i list.add(new Pair< Integer,Integer>(val1,val2));
}

返回列表;


当我尝试为Controller的方法加载页面时,我得到:

  URI:
/ clive-toolbox / cliveServices / attempt
Class:
groovy.lang.MissingMethodException
消息:
没有方法的签名:static tst.Replicate.create()适用于参数类型:(java.lang.Integer,java.lang.Integer,java .lang.Integer值:[20,1,1]可能的解决方案:grep(),iterator()

突出显示为错误的行是(在控制器中):

  def list = Replicate.create(计数器,val1,val2)

在其他情况下,以同样的方式,Grails设法编译项目,但只是不执行该方法。我认为我做错了什么。这里有任何想法吗?


请检查以下内容, $ b

  1。你已经输入了正确的课程。 
2.包名是正确的。
3.您已清理了您的应用程序。

尝试上述三种方法,如果方法在其他地方工作, p>

I'm starting with Grails (using mainly the Eclipse plugin) and have been having trouble with Grails reading Java src files - whether it's a jar in the bin folder, or a Java file in the src/java folder.

I've created an example of how I call from my controller, a Java static method, and for some reason there is a problem with the argument type. Here's the controller:

def attempt = {
    int counter = 20
    int val1 = 1
    int val2 = 1
    def list = Replicate.create(counter, val1, val2)
    render list.size()
}

And here is the Java file in the src/Java folder:

public class Replicate {

public static LinkedList<Pair<Integer, Integer>> create (int count, int val1, int val2){

    LinkedList<Pair<Integer, Integer>> list = new LinkedList<Pair<Integer,Integer>>();

    for (int i = 0; i < count; i++){
        list.add(new Pair<Integer, Integer>(val1, val2));
    }

    return list;
}
}

When I try and load the page for the Controller's method, I get:

URI:
/clive-toolbox/cliveServices/attempt
Class:
groovy.lang.MissingMethodException
Message:
No signature of method: static tst.Replicate.create() is applicable for argument types:     (java.lang.Integer, java.lang.Integer, java.lang.Integer) values: [20, 1, 1] Possible solutions:     grep(), iterator()

The line that is highlighted as the error is this (in the controller):

def list = Replicate.create(counter, val1, val2)

And in other cases, working the same way, Grails manages to compile the project but just doesn't execute the method. I assume I'm doing something wrong. Any ideas here?

解决方案

Your exception correctly states that the method Replicate.create() is not available to the controller. Check the following,

1. You have imported the class right.
2. Package name is correct.
3. You have cleaned your application.

Try all the three mentioned above, it might help if the method is working on other places.

这篇关于Grails - 方法的签名不适用于参数类型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆