When i use the hibernate validator in Spring MVC project (not based on Maven) i get Exception "java.lang.annotation.AnnotationFormatError".
From website tutorials i know that the Maven is not required if we import the hibernate validator jar files in our project ,although i import all required validator hibernate jar files in my project iam still get the exception but when i use Maven project where i move all the same files from Spring MVC prject to maven Spring MVC project the application and validators are run well.
My question is How can i use hibernate validator without using maven and without get any exception ?
My exception :
java.lang.annotation.AnnotationFormatError: Duplicate annotation for class: interface javax.validation.constraints.Min: @javax.validation.constraints.Min(message=must be more than 5 letters, groups=[], payload=[], value=5)
My controller Class :
package model;
import beans.Traveller;
import javax.validation.Valid;
import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.servlet.ModelAndView;
@Controller
public class Data {
@RequestMapping("/ViewJSP")
public ModelAndView method1(@Valid @ModelAttribute("Traveller1") Traveller traveller ,BindingResult bindingResult)
{
if (bindingResult.hasErrors())
{
ModelAndView mv = new ModelAndView("index");
return mv ;
}
ModelAndView mv = new ModelAndView("ViewJSP");
return mv ;
}
}
My bean class :
public class Traveller {
@Size(min=5,max=30)
private String name ;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
the hibernate jar files that i import in my project :
- classmate-1.3.4
- hibernate-validator-6.0.13.Final
- jboss-logging-3.3.2.Final
- validation-api-2.0.1.Final