Java – what settings do you need to make to use jsr-303 annotations in spring?

I downloaded spring 3 and put it on my classpath, but I couldn't import the @ valid annotation However, I can import other spring 3 Notes (such as @ controller) What jar is @ valid? Where and what package?

Editor: This is a JSR - 303 comment What does this mean and how to get it?

Solution

Missing javax validation.

You will find a jar here If you use maven, it depends on:

<dependency>
  <groupId>javax.validation</groupId>
  <artifactId>validation-api</artifactId>
  <version>1.0.0.GA</version>
</dependency>

To verify the actual work, you also need an implementation, such as hibernate validator Maven dependency:

<dependency>
  <groupId>org.hibernate</groupId>
  <artifactId>hibernate-validator</artifactId>
  <version>4.0.2.GA</version>
  <scope>runtime</scope>
</dependency>

JSR reference means that this is the standard for Java community process development, especially JSR number 303

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>