I am new to Java and maven. I might be missing something obvious, but I am not able to figure it out.
I was trying to add javax validations to my project following the link : https://www.baeldung.com/javax-validation
And I have added the following dependencies
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>2.0.1.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-validator</artifactId>
<version>6.0.13.Final</version>
</dependency>
<dependency>
<groupId>org.glassfish</groupId>
<artifactId>javax.el</artifactId>
<version>3.0.0</version>
</dependency>
I have tried group ids org.hibernate and org.hibernate.validator also.
But I was getting a runtime error during the execution of buildDefaultValidatorFactory() of:
import javax.validation.Validation;
import javax.validation.Validator;
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
I was getting the following error
Method threw 'javax.validation.NoProviderFoundException' exception.
Unable to create a Configuration, because no Bean Validation provider could be found. Add a provider like Hibernate Validator (RI) to your classpath.
What am I missing? Let me know if you need some key info. I have been fighting with this for hours. So, thanks in advance.
Remove the hibernate and glassfish validation. Just keep javax one. Clean your project properly.
Then right do project->runas->maven build ->clean install once.
At the same time you can update your project also click on project ->maven>update project