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.
Validation Starter no longer included in web starters from the Spring Boot version 2.3 : https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters
you should add it yourself.
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>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With