Reputation: 4460
I'm trying validating my beans using bean validator. The problem is I don't know which libraries(jar) are necessary to validation.
I'm using.
Vaadin 7, BeanFieldGroup and EclipseLink
/** class of MyBean */
public class MyBean{
@Id
@GeneratedValue
private Long id;
@NotNull
@NotEmpty
@Size(min=5, max=50, message="Min = 5 and Max = 50, this field is not empty")
private String name;
@Email
@NotEmpty
private String email;
}
Any idea ?
Upvotes: 0
Views: 4109
Reputation: 698
It depends on a few factors but the best you can do is to look for a README.md file inside the archive you downloaded. In my case that was hibernate-validator-5.4.0.Final.jar from the JBoss site. In there, among other things there's a section called "Using Hibernate Validator"
Using Hibernate Validator
In case you use the distribution archive from the download site, copy dist/hibernate-validator-<version>.jar together with all jar files from dist/lib/required into the classpath of your application. For the purposes of logging, Hibernate Validator uses the JBoss Logging API, an abstraction layer which supports several logging solutions such (e.g. log4j or the logging framework provided by the JDK) as implementation. Just add a supported logging library to the classpath (e.g. log4j-<version>.jar) and JBoss Logging will delegate any log requests to that provider.
+1 for the other answer that teaches you how to create a user defined library so you can group those files neatly into one convenient bundle.
Upvotes: 0
Reputation: 8219
Follow these step-by-step instructions on how to download and configure Hibernate Validator in your Eclipse project:
validation-api-1.1.0.Final.jar
and hibernate-validator-5.1.0.Final.jar
filesvalidation-api-1.1.0.Final.jar
tree nodevalidation-api-1.1.0.Final-sources.jar
validation-api-1.1.0.Final.jar
tree nodevalidation-api-1.1.0.Final-javadoc.jar
hibernate-validator-5.1.0.Final.jar
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:
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...
Upvotes: 6