Issue
We are currently using jdk 14, spring boot 2.2.8.RELEASE, and Kotlin 1.5.31. the below class used to error on blank first or name.
now that we are trying to update to spring boot 2.5.4 it's no longer throwing the error in our automated test case.
data class ChangeInformationRequest(
@field:NotBlank var firstName: String,
@field:NotBlank var lastName: String,
@field:Valid var address: Address?
)
Solution
The issue is that the Spring Boot validation starter is no longer included in web starters (which I am guessing you are using) from Spring Boot 2.3 (https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes#validation-starter-no-longer-included-in-web-starters). This means that spring-boot-starter-validation
is no longer a transitive dependency of spring-boot-starter-web
or spring-boot-starter-webflux
. As a consequence you have to actually add the dependency yourself to your pom.xml
as follows:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
I suggest you go through all the relevant Spring Boot release notes so that you can learn upfront which are the major changes that might affect your code:
- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.3-Release-Notes
- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.4-Release-Notes
- https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.5-Release-Notes
Answered By - João Dias
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.