我正面临这个错误
groovy.lang.GroovyRuntimeException:找不到匹配项 构造函数:AnimalInfoType(java.lang.String,java.lang.Integer, java.lang.Integer)何时
通过" run-app"启动应用程序我已经为Enum创建了构造函数,如下所示:
package jogoanimais
public enum AnimalInfoType
{
ANIMAL(1),
ACTION(2)
final int value
private AnimalInfoType(int value) {
this.value = value
}
int value() { value }
}
我的域名类似:
class AnimaisTreeMap {
String nodeDescription
AnimalInfoType nodeInfo
AnimaisTreeMap yesAnswerNode
AnimaisTreeMap noAnswerNode
static constraints = {
yesAnswerNode nullable:true
noAnswerNode nullable:true
}
static mappedBy = [ yesAnswerNode: "none", noAnswerNode: "none" ]
static mapping = {
yesAnswerNode cascade: 'delete'
noAnswerNode cascade: 'delete'
}
}
在我的BootStrap.groovy,我就这样填写表格:
def noAnswer = new AnimaisTreeMap(nodeDescription:"macaco",
nodeInfo: AnimalInfoType.ANIMAL,
noAnswerNode:null,
yesAnswerNode:null)
noAnswer.save(failOnError: true)
def yesAnswer = new AnimaisTreeMap(nodeDescription:"tubarão",
nodeInfo: AnimalInfoType.ANIMAL,
noAnswerNode:null,
yesAnswerNode:null)
yesAnswer.save(failOnError: true)
new AnimaisTreeMap(nodeDescription:"vive na água",
nodeInfo: AnimalInfoType.ACTION,
noAnswerNode: noAnswer,
yesAnswerNode: yesAnswer).
save(failOnError: true)
}
我在BootStrap.groovy做错了什么?
答案 0 :(得分:1)
删除枚举构造函数及其公共定义。没有必要,默认情况下所有类都是公开的。
编辑由Enum结束的课程。 AnimalInfoTypeEnum。
enum AnimalInfoTypeEnum
{
ANIMAL(1),
ACTION(2)
final int value
int value() { value }
}
答案 1 :(得分:0)
也许试试这个:
package jogoanimais
enum AnimalInfoType{
ANIMAL(1),
ACTION(2)
private final int value
private AnimalInfoType(int value) {
this.value = value
}
int value() { value }
}
不会让我评论,没有足够的代表。