我有简单的验证,例如:
@Column(length=6)
@Pattern(regexp = "[0-9]{2}( |-)?[0-9]{3}", message = Errors.kod_pocztowy)
private String kod_pocztowy;
但它返回奇怪的错误:
failed: java.lang.NoClassDefFoundError: javax/el/ELContext
[error] at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateExpression(ResourceBundleMessageInterpolator.java:227)
[error] at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolateMessage(ResourceBundleMessageInterpolator.java:187)
[error] at org.hibernate.validator.messageinterpolation.ResourceBundleMessageInterpolator.interpolate(ResourceBundleMessageInterpolator.java:115)
[error] at org.hibernate.validator.internal.engine.ValidationContext.interpolate(ValidationContext.java:370)
[error] at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolation(ValidationContext.java:284)
[error] at org.hibernate.validator.internal.engine.ValidationContext.createConstraintViolations(ValidationContext.java:246)
[error] at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateSingleConstraint(ConstraintTree.java:289)
[error] at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:133)
[error] at org.hibernate.validator.internal.engine.constraintvalidation.ConstraintTree.validateConstraints(ConstraintTree.java:91)
[error] at org.hibernate.validator.internal.metadata.core.MetaConstraint.validateConstraint(MetaConstraint.java:85)
[error] at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraint(ValidatorImpl.java:478)
[error] at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForDefaultGroup(ValidatorImpl.java:424)
[error] at org.hibernate.validator.internal.engine.ValidatorImpl.validateConstraintsForCurrentGroup(ValidatorImpl.java:388)
[error] at org.hibernate.validator.internal.engine.ValidatorImpl.validateInContext(ValidatorImpl.java:340)
[error] at org.hibernate.validator.internal.engine.ValidatorImpl.validate(ValidatorImpl.java:158)
当我将消息属性更改为如下文本时:
@Column(length=6)
@Pattern(regexp = "[0-9]{2}( |-)?[0-9]{3}", message = "Now its ok")
private String kod_pocztowy;
然后一切似乎都很好。有什么问题?任何人都可以为我解释一下吗?