Which version of Spring Framework version we should go with
In recent days, I have been discussing with my friends on what is the best Spring Framework should be on in order to get full comprehensive of the powerful of Spring Framework.
I think most of the legacy open source projects on github are still on Spring 5.X.
But if you look at the Spring Framework 6.0 was last year November release.
No matter you are using Spring Tool Suite or IDEA, you can see it was already available as default selection of your new spring boot project wizard.
And Spring Boot 3.0 was based on Spring Framework 6.0
So personally i will highly recommend any new projects that will be started should go with Spring Framework 6.0 and Spring Boot 3.0. Also the legacy projects are using Spring framework 5.X and Spring boot 2.7.X should be considered to migrate to 6.0 and 3.0 as well.
So why should go with Spring Framework 6.0?
1. JDK and Jakarta EE
Fully support JDK 17+ which means it is faster, no more support of JDK 8 or JDK 11. As the primary Java Web Open Source Framework, this is what it will go with in future. Most of the current applications/projects will go with JDK upgrade soon as in my opinion.
Also included Jakarta EE 9+ support, Jakarta EE is the original JAVAEE with the new name only. So if you started to use Spring Framework 6.0, you can see Servlet,JPA APIs packages has changed from javax to jakarta already.
2. Better support newer version of web server
Compatible with Tomcat 10.1, Jetty 11, Undertow 2.3
3. Usage of virtual threads
virtual threads is the JDK 19 new feature, based on the use case scenario, it can be used in Higher concurrency。
If you want to run with this JDK new feature, you can use this as run with virtual threads in Spring Framework 6.0
Anyone interested on this, you can google as Virtual Threads vs Platform Threads. This will give you more ideas on what it is about.
4. Unit Testing
Much more easier ways to mock servlet api as HttpServletRequest, HttpSession etc. You can use the MockHttpServletRequest, MockHttpSession in Spring Framework 6.0.
So Spring Framework 6.0 is the version you should go with now. Not 5.X anymore.