I just migrated my application from spring boot version 2.7.4
to 3.2.1
. (Disclaimer: Had to put in a few hacks). From my personal experience, I can say that it's technically possible to have both javax
and jakarta
libs in a Spring Boot 3 app, however, it's strongly discouraged for the following reasons:
Compatibility Issues:
- Class Loading Conflicts: Having both sets of classes in the classpath can lead to conflicts and unpredictable behavior, as classes with the same name but different package names might clash.
- API Incompatibilities: Jakarta EE 9 introduces some API changes that aren't compatible with older Java EE APIs. Using both simultaneously can create unexpected errors.
- Third-Party Library Issues: Some third-party libraries might not be compatible with Jakarta EE 9 yet, and mixing them with jakarta libs could cause issues.
Deployment Challenges:
- Jakarta-Compatible Servers: Servers like Tomcat 10 are designed for Jakarta EE 9, and relying on javax libs might lead to deployment errors or unexpected behavior.
- Class Loading Isolation: Separating javax and jakarta libs within the server might not be straightforward, potentially causing conflicts.
Recommendations:
Full Migration:
- It's highly recommended to fully migrate your application to Jakarta EE 9 to ensure compatibility and avoid potential issues. This involves:
- Updating Spring Boot to version 3.
- Updating dependencies to Jakarta EE 9 versions.
- Refactoring code to use jakarta package names.
Temporary Workaround:
- If full migration isn't immediately feasible, consider:
- Using Spring Boot 2.7 as a temporary solution, as it supports both javax and jakarta APIs.
- Selectively updating dependencies to Jakarta EE 9 versions where possible, while keeping those without Jakarta-compatible versions on javax.
Important Considerations:
- Thorough Testing: If you choose to mix javax and jakarta libs, conduct thorough testing to identify potential compatibility issues early on.
- Dependency Management: Carefully manage dependencies to ensure correct versions and avoid conflicts.
- Third-Party Library Updates: Stay updated on third-party library compatibility with Jakarta EE 9 to plan future migration steps.
Ultimately, the goal should be to fully migrate to Jakarta EE 9 for long-term compatibility, stability, and alignment with the latest Spring Boot standards.
For Spring v2 to v3 migration, this official guide may be helpful https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-3.0-Migration-Guide