【发布时间】:2014-10-31 11:48:20
【问题描述】:
我想将枚举的所有可用值添加到hibernate validation 消息中。但我不能,因为它需要一个常量表达式。
@NotNull(message = "Allowed values: " + MyEnum.values());
结果错误:
The value for annotation attribute NotNull.message must be a constant expression
如何做到这一点?
【问题讨论】:
-
你不能,但你可以创建一个自定义约束来验证 MyEnum 值。
标签: java hibernate enums hibernate-validator