🔹 1. jakarta.validation-api
This provides the standard interface (API) for bean validation.
It includes annotations like:
Dependency:
🔸 But: this is only the API, not the implementation.
You still need something to run these validations (see below).
🔹 2. spring-boot-starter-validation
This is a Spring Boot starter that:
-
Automatically includes the
jakarta.validation-api
-
Adds the actual implementation (Hibernate Validator)
-
Integrates validation into Spring Boot (like
@Valid
in controllers)
Dependency:
✅ So Which One Should You Use?
You should only use:
Because:
-
It already includes
jakarta.validation-api
-
It also brings in Hibernate Validator
-
Works perfectly with Spring Boot MVC / REST with
@Valid
✨ Example in Spring Boot:
In controller:
No comments:
Post a Comment