Five Things You Need to Know About the Spring Framework 5

Spring FrameWork 5 Main Logo

Five Things You Need to Know About the Spring Framework 5

This week, immediately after the release of Java 9, a new major version of one of the most popular frameworks for developing a Java application – the Spring Framework version 5 – was released. Under the kit, details and a brief description of what has changed.

Java 9 support

As you might expect, the new Spring feels quite comfortable working on the new version of Java. This means that the new version of Spring will work as included in the classpath, and in the module path (using automatic modules). The assembly and all tests of the framework itself work on the new JDK9 (although by default they still use JDK8).

Reactivity

The new version of the framework adds a new project to the Spring collection – Spring Reactive Web Framework or WebFlux. This is a fully asynchronous and non-blocking web framework designed to work on top of the event loop, as an alternative to traditional servlets working on top of the classic thread pool.

Moreover, since The new reactive web is not development, but rather a parallel direction with Spring MVC, it allows you to work outside the servlet containers and even create minimalistic microframework-like applications – using a functional approach with WebFlux.fn.

Kotlin Support

Kotlin is now not only officially supported by the Google language for development on Andriod, but also officially supported by Spring-language for backend development.

Kotlin support includes several aspects:

  • Functional Kotlin DSL for describing the components of the WebFlux application (beans) and routers
  • Support for Kotlin Script as a view engine using ScriptTemplateView
  • Support for immunity classes, optional parameters, default values, and much more
  • Ability to create a new project using Spring Initializr on Kotlin

The fact is, to assess the scale and severity of the code on Kotlin in the Spring kernel is already larger than Groovy.

New Documentation

The official documentation was restructured and broken down into small modules, grouped by functionality.

Other changes

There are a lot of them, but there are several key ones:

  • Null-safety using the JSR-305 annotation. With these annotations, Kotlin can work, and Java code analysis tools (for example, IDEA understands them, as well as FindBugs)
  • Compatible with Java EE 8 – Servlet 4.0, Bean Validation 2.0, JPA 2.2, JSON Binding API 1.0, Tomcat 9.0, Hibernate Validator 6.0
  • Functional registration of components (beans) or WebFlux.fn – now DI can be configured not only through annotations and XML, but also simply by code, referring directly to the application context
  • New common logging bridge – spring-jcl (which automatically knows how to work with Log4j 2.x, SLF4J, java.util.logging)
  • Improvements in the test framework – support for JUnit 5, parallel execution of tests

Conclusion

In general, there are a lot of changes, the new framework is the result of several years of work on the project. You can try the new Spring 5 using either the Spring Boot 2.0 build snapshot or the M5 version that will be released next week. The final version of Spring Boot 2.0 is expected closer to the end of this year.