spring3 mvc @Valid注释找不到
我尝试使用@Valid注释,但eclipse总是给出“Valid无法解析为类型”错误。我正在使用 spring3 库。
我已将 hibernate-validator-4.1.0.Final.jar 导入到 WEB-INF/lib 目录中。然而,这并不能解决问题。
任何帮助表示赞赏!
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!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
@Valid
属于 JSR-303。您可以使用此依赖项通过 maven 获取它:或者您可以下载它 从这个页面。
@Valid
belongs to JSR-303. You can get it via maven using this dependency:Or you can download it from this page.
我有同样的问题(Maven 项目)。我按照下面的步骤操作,它起作用了:
保存,Maven 将自动下载依赖项 jar 文件
重启应用
注意:不必提及版本,因为它已经在 Spring Boot 依赖项中定义。否则,以下应该有效:
来源:https://mvnrepository.com/工件/javax.validation/validation-api/2.0.1.Final
I had the same issue(Maven project). I followed below and it worked:
Save and Maven will automatically download dependency jar files
Restart application
Note: Did not have to mention version as it was already defined in Spring Boot Dependencies. Otherwise below should work:
Source: https://mvnrepository.com/artifact/javax.validation/validation-api/2.0.1.Final
据我所知,@Valid注释是validation-api JAR的一部分,您可以在Hibernate验证器的lib目录中找到它,因为您已经下载了Hibernate实现。
@Valid
是 javax.validation 注释 API 的一部分。您可以将此 JAR 添加到类路径中,以便能够正确引用注释。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.