Search code examples
springspring-boottomcat

Spring boot 3 - Jakarta and Javax


In the new Spring boot 3 Release notes, They tells that this version is going to use Jakarta EE 9 (libs named as jakarta) instead of JEE (libs named as javax).

They advise developers to replace imported javax with jakarta in this article.

If I have a spring boot app with both, javax and jakarta libs, will the app work and be able to be deployed in a Jakarta compatible server (e.g. Tomcat 10)?


Solution

  • The answer will really depend on which specific libraries you're using and how they interact with each other, but generally speaking, trying to mix Java EE and Jakarta EE would be a bad idea.

    As an example, if you're writing a Spring MVC application, you'll be using DispatcherServlet. In Spring Framework 6, this will require the Jakarta Servlet API. There's not going to be a way to make it work with javax.servlet. For other APIs, if you're using them directly and you're not making use of Spring abstractions that build on them, you may get away with having them on your classpath. I still wouldn't recommend it.