You need to add the @Valid
annotation.
@PutMapping("/")
ResponseEntity updateOptions(
@Valid @RequestBody RequestDto requestDto
);
If you are using Spring Boot 2.3
and higher, we also need to add the "spring-boot-starter-validation" dependency:
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-validation</artifactId>
</dependency>
For more detailed examples you can review the article "Validation in Spring Boot".
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…