Spring-Boot-2.3 requires javax.validation to be added as a dependency

Where the validation function was implemented using Spring Boot 2.3.1. Annotations such as @Size and @NotNull (javax.validation *) were no longer available.

Conclusion

Added the following dependencies.

for maven

<dependency>
  <groupId>org.springframework.boot</groupId>
  <artifactId>spring-boot-starter-validation</artifactId>
</dependency>

For gradle

dependencies {
  ...
  implementation 'org.springframework.boot:spring-boot-starter-validation'
}

Reason

When using version 2.3 or earlier, the javax.validation * library could be used by loading the following starter. It seems that it was not included from 2.3.

implementation 'org.springframework.boot:spring-boot-starter-web'

Reference https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters

Recommended Posts

Spring-Boot-2.3 requires javax.validation to be added as a dependency
How to run the SpringBoot app as a service
To not be a static uncle
There seems to be a word "de-Java".
[SpringBoot] How to write a controller test
Pass the condition to be used in the Java8 lambda expression filter () as a parameter