Spring 5 was released in late 2017. Spring 5 brings a massive update to the Spring framework. Spring 4 was released in 2013, so everybody was expecting a major overhaul of the framework. I am very happy to see the new features in Spring framework.
Spring 5 runs on Java 8, so spring code can leverage lambda expressions to improve code readability.
Spring 5 also supports java 9, so we can create our applications on module based architecture too.
Spring 5 supports Java EE 7 and also compatible with Java EE 8. So we can use Servlet 4.0, Bean Validation 2.0, JPA 2.2 in our applications. We can also use their older versions i.e. Servlet 3.1, Bean Validation 1.1, JPA 2.1.
Spring 5 applications preferred server versions are Tomcat 8.5+, Jetty 9.4+ and WildFly 10+.
I really like that spring 5 is trying to catch up to the latest version of different technologies.
Non-null API declaration at the package level. Nullable arguments, fields and return values are explicitly annotated with @Nullable annotation.
File operations are performed via NIO 2 streams i.e. no FileInput/Output Stream. This is a great enhancement and performance boost for file based applications.
Spring Framework 5.0 comes with its own Commons Logging bridge; spring-jcl instead of standard Commons Logging.
Support for providing spring components information through index file “META-INF/spring.components” rather than classpath scanning. This will improve startup time a lot if you have a large spring project and many spring components. It will be better for developers too, because we can directly look into specified files to figure out the application entry point rather than searching through the entire classpath files.
Spring WebFlux is the new module, it’s an alternative to spring-webmvc module and built on reactive framework. This module is used to create fully asynchronous and non-blocking application built on event-loop execution model.
Reactive infrastructure in spring-core such as Encoder and Decoder for encoding and decoding streams of Objects.
@Controller style, annotation-based, programming model, similar to Spring MVC, but supported in WebFlux, running on a reactive stack.
New WebClient with a functional and reactive API for HTTP calls, comparable to the RestTemplate but through a fluent API and also excelling in non-blocking and streaming scenarios based on WebFlux infrastructure.
Spring 5 also supports Kotlin programming now. This is a huge step towards supporting functional programming, just as Java is also moving towards functional programming.
Support for Null-Safe API
Support for Kotlin immutable classes with optional parameters and default values.
Leveraging Kotlin reified type parameters to avoid specifying explicitly the Class to use for serialization/deserialization in various APIs like RestTemplate or WebFlux APIs.
Support for Kotlin autowired constructor with optional parameters.
Removed packages beans.factory.access, jdbc.support.nativejdbc, mock.staticmock from spring-aspects module.
Removed packages web.view.tiles2 and orm.hibernate3/hibernate4 dropped. This means if you are planning to use Spring 5, you will also have to use Hibernate 5.
Dropped support for old technologies Portlet, Velocity, JasperReports, XMLBeans, JDO, Guava. If you are using any of these, then either migrate to some other technologies or stay with Spring 4.
That’s all for a quick overview of Spring 5 features. Reference: Spring GitHub Doc
Thanks for learning with the DigitalOcean Community. Check out our offerings for compute, storage, networking, and managed databases.
While we believe that this content benefits our community, we have not yet thoroughly reviewed it. If you have any suggestions for improvements, please let us know by clicking the “report an issue“ button at the bottom of the tutorial.
I’m disappointed that support for JDO has been dropped. It always seemed to me to be the best persistence technology, and the companies I work for have used JDO widely in production, and are currently shipping and planning new products with use JDO persistence.
I’m disappointed that support for JDO has been dropped. It always seemed to me to be the best persistence technology, and the companies I work for have used JDO widely in production, and are currently shipping and planning new products with use JDO persistence.
- Steve Zara
Good to know and thanks for the info.
- Chiranjeevi