问题
I try to use @Valid annotation, but eclipse always gives the "Valid cannot be resolved to a type" error. I m using the spring3 library.
I have imported hibernate-validator-4.1.0.Final.jar into my WEB-INF/lib directory. however, this does not solve the problem.
Any help is appreciated!
回答1:
As far as I remember the @Valid
annotation is part of the validation-api JAR which you can find in the lib directory of the Hibernate Validator, as you have already downloaded the Hibernate implementation. The @Valid
is a part of the javax.validation annotation API. You can add this JAR to your class path to be able to properly reference the annotation.
回答2:
@Valid
belongs to JSR-303. You can get it via maven using this dependency:
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.0.0.GA</version>
</dependency>
Or you can download it from this page.
来源:https://stackoverflow.com/questions/4098697/spring3-mvc-valid-annotation-cannot-be-found