我想使用枚举来表示一些选择值。在
/src/groovy
文件夹,在包下
com.test
,我有这个枚举:
package com.test
public enum TabSelectorEnum {
A(1), B(2)
private final int value
public int value() {return value}
}
现在,我尝试从控制器访问它,比如:
TabSelectorEnum.B.value()
但它抛出了一个例外:
Caused by: org.codehaus.groovy.runtime.InvokerInvocationException: java.lang.NoClassDefFoundError: Could not initialize class com.test.TabSelectorEnum
我做错什么了?
更新:在我清理并重新编译之后,错误代码更改为:
groovy.lang.GroovyRuntimeException: Could not find matching constructor for: com.test.TabSelectorEnum(java.lang.String, java.lang.Integer, java.lang.Integer)
看起来访问枚举值的方式有问题,但我不知道是什么。