Issue
I already have this dependency in my pom.xml file
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
And have refreshed Maven and already restarted IntelliJ but always get this error
java: package javax.validation.constraints does not exist
It cannot find this package for some reason. But this error occurs only when I try to compile.
In my Entity class I imported import javax.validation.constraints.Size;
and want to add an annotation to a column for example:
@Size(min = 1)
private String name;
or
@DecimalMin("0.01")
private BigDecimal amount;
But always I get the problem with the validation package.
There is no error message in the IDE, the error appears when I run.
Solution
I used it like this in my Spring app and it worked.
<dependency>
<groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId>
<version>1.1.0.Final</version>
</dependency>
Answered By - sproketboy
Answer Checked By - Candace Johnson (JavaFixing Volunteer)