我在所有域类的 Spring Tool Suite 中收到此“错误”。它不是真正的错误,因为它编译得很好。但它掩盖了真正的编译错误,我该如何摆脱它?它们在同一个包中,所以我不需要导入,如果我添加导入它说它找不到类......
所以下面的代码产生一个红色的 x
Groovy:Apparent variable 'ExampleB' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
package domain.com.so;
class ExampleA {
static belongsTo = [exampleB: ExampleB]
static constraints = {
}
}
这段代码产生了一个类似的错误:
Groovy:Apparent variable 'ExampleA' was found in a static scope but doesn't refer to a local variable, static field or class. Possible causes:
package domain.com.so;
class ExampleB {
static hasMany = [exampleAs: ExampleA]
static constraints = {
}
}
最佳答案
通常当 STS 提示这样的事情时,我会跑
grails clean
和
grails compile --refresh-dependencies
关于grails - Groovy:在静态作用域中发现了明显变量 xyz,但不引用局部变量、静态字段或类。可能的原因:,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15769863/