Groovy/Grails - 运行-应用枚举错误

Groovy/Grails - Error at run-app with Enums

我遇到了这个错误

groovy.lang.GroovyRuntimeException: Could not find matching constructor for: AnimalInfoType(java.lang.String, java.lang.Integer, java.lang.Integer) when

通过 "run-app" 启动应用程序,我已经为枚举创建了构造函数,如下所示:

    package jogoanimais

    public enum AnimalInfoType
    {
      ANIMAL(1), 
      ACTION(2)

        final int value
        private AnimalInfoType(int value) {
          this.value = value
        }

        int value() { value }    
    }

我的域名class是这样的:

    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 处,我填写 table 是这样的:

    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 做错了什么?

也许试试这个:

package jogoanimais

enum AnimalInfoType{
   ANIMAL(1), 
   ACTION(2)

   private final int value

   private AnimalInfoType(int value) {
      this.value = value
   }

   int value() { value }
}

不让我发表评论,没有足够的代表。

删除枚举构造函数及其 public 定义。没必要,所有class默认都是public。

并编辑以 Enum 结尾的 class。动物信息类型枚举。

enum AnimalInfoTypeEnum
{
  ANIMAL(1), 
  ACTION(2)

    final int value

    int value() { value }    
}