Follow these step-by-step instructions on how to download and configure Hibernate Validator in your Eclipse project:
- Download the following Hibernate Validator files from JBoss Repository:
- Select your project's root in Eclipse
- Go to Window -> Preferences -> Java -> Build Path -> User Libraries view
- Click New... button on the right to open New User Library window:
- enter your library name (i.e. Hibernate Validator 5.1.0)
- click OK button to accept
- Click Add External JARs... button on the right to open JAR Selection window:
- select the previously downloaded
validation-api-1.1.0.Final.jar
andhibernate-validator-5.1.0.Final.jar
files - click Open button to add them into Hibernate Validator 5.1.0 library
- select the previously downloaded
- Select Source Attachment under
validation-api-1.1.0.Final.jar
tree node - Click Edit... button on the left to open Source Attachment Configuration window:
- select External location radio button
- click External File... button to open JAR/ZIP File Selection window
- select the previously downloaded
validation-api-1.1.0.Final-sources.jar
- click Open button to set up Location path in the parent window
- click OK button to accept
- Select Source Attachment under
validation-api-1.1.0.Final.jar
tree node - Click Edit... button on the left to open Javadoc For 'hibernate-validator-5.1.0.Final.jar' window:
- select Javadoc in archive radio button
- select External File... radio button
- click Browse... button to open Javadoc Archice Selection window
- select the previously downloaded
validation-api-1.1.0.Final-javadoc.jar
- click Open button to set up Archive path in the parent window
- click OK button to accept
- Repeat steps 6-9 for
hibernate-validator-5.1.0.Final.jar
- Click OK button in User Libraries view.
In a moment Eclipse is ready to work with Bean Validation constraints.
In fact you could end up the configuration on step 5) as this is all you need to make Bean Validation work, however development is much more comfortable if a given main .jar is associated with its corresponding -javadoc and -sources libraries as it gives you opportunity to:
- view Javadoc comments - F2
- view source files - F3
respectively for the selected constraint in Eclipse Java Editor.
Now, imagine you can achieve the same with a single step (well, almost) using Maven but that's another story for another time...