0

我正在用 Groovy 编写一个小型测试应用程序。我有以下代码。

class Address {

static constraints = {
    street(blank:false, maxSize:100)
    residencenumber(min:1, max:65000)
    addition()
    zip()
    city(blank:false, maxSize:100)
    county()
    country(blank:false, maxSize:50)
}

String street
String zip
int residencenumber
String addition
String city
String county
String country

String toString() {
    return street + " " + residencenumber + " " + zip + " " + city + " " + country
}

}

我收到了这个相当神秘的信息。

nojevive@follett:~/dev/code/mysmallapp$ grails generate-all 地址 欢迎使用 Grails 1.1.1 - http://grails.org/ 获得 Apache Standard License 2.0 许可 Grails 主页设置为:/home/nojevive/dev /圣杯

基本目录:/home/nojevive/dev/code/mysmallapp 运行脚本 /home/nojevive/dev/grails/scripts/GenerateAll.groovy 环境设置为开发 groovy.lang.MissingMethodException: No signature of method: java.lang.Integer.call() is applicable for argument types: () values: [] at Project$__clinit__closure1.doCall(Project.groovy:11) at Project$__clinit__closure1.doCall(Project.groovy) at Project.getProperty(Project.groovy) at _PluginDependencies_groovy$_run_closure6_closure53.doCall(_PluginDependencies_groovy:467) at _PluginDependencies_groovy$_run_closure6_closure53.doCall(_PluginDependencies_groovy) at _GrailsSettings_groovy$_run_closure10.doCall(_GrailsSettings_groovy:274) at _GrailsSettings_groovy$_run_closure10.call(_GrailsSettings_groovy) at _PluginDependencies_groovy$_run_closure6.doCall(_PluginDependencies_groovy:447) at _GrailsBootstrap_groovy$_run_closure1.doCall(_GrailsBootstrap_groovy:74) at _GrailsGenerate_groovy$_run_closure1.doCall(_GrailsGenerate_groovy:37) at GenerateAll$_run_closure1.doCall(GenerateAll.groovy:42) at gant.Gant$_dispatch_closure4.doCall(Gant.groovy:324) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy:334) at gant.Gant$_dispatch_closure6.doCall(Gant.groovy) at gant.Gant.withBuildListeners(Gant.groovy:344) at gant.Gant.this$2$withBuildListeners(Gant.groovy) at gant.Gant$this$2$withBuildListeners.callCurrent(Unknown Source) at gant.Gant.dispatch(Gant.groovy:334) at gant.Gant.this$2$dispatch(Gant.groovy) at gant.Gant.invokeMethod(Gant.groovy) at gant.Gant.processTargets(Gant.groovy:495) at gant.Gant.processTargets(Gant.groovy:480) Error loading plugin manager: No signature of method: java.lang.Integer.call() is applicable for argument types: () values: []

首先我想也许我的号码超出了范围(我有 1000000)。然后我想也许这个号码是一个内置名称,所以我重命名为 Residencenumber。但没有运气。我在这里想念什么?我现在删除了所有约束,但仍然是相同的消息。所以它与我猜的领域无关。有什么东西一定要坏掉吗?

4

2 回答 2

1

我知道你已经解决了这个问题,但是更好的 toString 方法是:

String toString() {
  "$street $residencenumber $zip $city $country"
}
于 2009-07-16T08:21:32.040 回答
0

我可能错了,但我认为您正在将 int 添加到 String。我尝试:

street + " " + residencenumber.toString() +...
于 2009-07-14T20:32:24.477 回答