簡體   English   中英

Groovy:groovy.lang.MissingMethodException:方法未簽名

[英]Groovy : groovy.lang.MissingMethodException: No signature of method

我只是從常規開始。 此錯誤看起來很基本。 但我似乎沒有解決這個問題。 感謝任何指導我正確方向的幫助

我正在定義一個如下所示的字符串,並將其傳遞給testSender方法

def line = "5 1 -81.42 Ido1"
testSender(line.toString())

testSender方法的定義

def testSender(line){
     try {
         println line  
     } catch(e) {
         println e.printStackTrace()
     }
}

當我運行它時,出現此錯誤

groovy.lang.MissingMethodException: 
No signature of method: GroovySQLQuery$_main_closure1.testSender() 
is applicable for argument types: (java.lang.String) values: [5 1 -81.42 Ido1]

應該:

class GroovySQLQuery { 
    static void main(String[] args) { 
        def line = "5 1 -81.42 Ido1" 
        testSender(line.toString()) 
    } 

    static testSender(line) { 
        println line 
    } 
}

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM