Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Spring Boot 3.0 package javax.validation does not exist

I'm trying to use a method parameter validation feature supported by Bean Validation 1.1. For instance, the following method triggers the validation of the first parameter, making sure it's valid:

public String generateOtp(@Valid TotpAuthenticatorForm form, BindingResult bindingResult)

When I build a Spring Boot 2.7.7 project it's fine, but building a Spring Boot 3.0.1 project fails with a compilation error:

package javax.validation does not exist

How do I fix the issue?

like image 200
Boris Avatar asked Nov 29 '25 08:11

Boris


1 Answers

According to the release-notes, Spring Boot 3.0 has migrated from Java EE to Jakarta EE APIs for all dependencies, including:

Jakarta Validation 3.0
  • Spring Boot 2.7 - Jakarta Bean Validation 2.0
  • Spring Boot 3.0 - Jakarta Bean Validation 3.0

You can fix the issue by using Jakarta Bean Validation 3.0. Simply update import statements:

javax.validation
->
jakarta.validation
like image 96
Boris Avatar answered Dec 02 '25 02:12

Boris



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!