Video in progress
Why did the javax.* imports change to jakarta.* in Spring Boot 3, and which Java version do you need?
Java EE moved to the Eclipse Foundation and became Jakarta EE, and for legal reasons the javax name could no longer be used. Spring 6 and Boot 3 are built on Jakarta EE 9+, and the minimum Java is 17.
📖 Answer
The thing that changes most in moving from Boot 2 to 3 is the imports:
// Boot 2
import javax.persistence.Entity;
import javax.validation.constraints.NotNull;
import javax.servlet.http.HttpServletRequest;
// Boot 3
import jakarta.persistence.Entity;
import jakarta.validation.constraints.NotNull;
import jakarta.servlet.http.HttpServletRequest;
Why: Oracle handed Java EE over to the Eclipse Foundation, but didn't transfer the rights to the javax namespace. So in Jakarta EE 9 all the packages were moved to jakarta.*.
Not every javax moved: javax.sql.DataSource and javax.crypto are part of the JDK itself and stayed. Only the enterprise APIs (persistence, validation, servlet, annotation, transaction) moved.
What it means in practice:
- Java 17 minimum;
- Hibernate 6, Tomcat 10+;
- if an old library still depends on
javax.servlet, it won't work with Boot 3, and you have to find a newer version; - it's easier to change the imports with OpenRewrite or an IDE migration than by hand. In a migration, most of the time usually goes into those old libraries.
Sign up to mark studied questions and save your progress.