Features Of Spring Framework 5

Features Of Spring Framework 5:-

Spring releases its one of the major version releases in the form of Spring 5  since its release of version 4. We are going to list out Features Of Spring Framework 5.

Spring indeed has gone long way in terms of features and implementations.This is the most exciting release of spring with JDK 8 and JDK 9 support. One of the exciting feature to look for is reactive programming and kotlin support in Spring. Here are some of cool Features Of Spring Framework 5 to look for.

  1. JDK and Java EE baselining
  2. Package Cleaning and Updates
  3. Core Framework Revision
  4. Functional Programming Support with kotlin
  5. Reactive Programming Model
  6. Testing Improvements

JDK and Java EE baselining:-

  1. Entire Codebase is on JDK 8, with support for lambda, generics etc.
  2. Code Is Fully compatible with JDK 9 and completely tested..
  3. Java EE 7 API level required and Support for Java EE 8 API level in Spring’s corresponding features now.

Package Cleaning and Updates:

  1. Dropped Support for Portlet, Velocity, JasperReports, XMLBeans, JDO, Guava
  2. Templating and ORM require minimum Tile 3 and Hibernate 5
  3. Package mock.staticmockremoved from the modulespring-aspects.

Core FrameWork Revison:-

  1. Spring has redesigned to use new features present in JDK 8.
  2. We can use Selective declarations of Java 8 default methods on Springs core interfaces.
  3. Spring Core API no more will tolerate null values eg:- StringUtils.
  4. @Nullable @NotNull provides more flexibility and avoid NullPointer Exceptions and gives an option to resolve compile time .

Functional Programming Support with kotlin:-

Spring Framework 5 brings in support for Kotlin in this release.It has been most awaited feature in Spring Framework 5.Kotlin is a statically-typed language running on the JVM and can be used alongside with Java.Spring uses Kotlin’s extensions capability to add Kotlin specific programming feature to existing Spring APIs.

We can now register the bean in Spring Framework 5 in a more functional way using lambdas as an alternative to Java-based Configurations in Spring 4.

Java Based:-

GenericApplicationContext context = new GenericApplicationContext();
context.registerBean(Bar.class, () -> new

Kotlin Based:-

val context = GenericApplicationContext().apply {
    registerBean { Bar(it.getBean<Foo>()) }

The New Spring Framework 5 has support for  Kotlin routing DSL that allows one to leverage the WebFlux functional API

(accept(APPLICATION_JSON) and "/api").nest {
            "/blog".nest {
                GET("/", blogHandler::findAll)
                GET("/{id}", blogHandler::findOne)

            "/event".nest {
                GET("/", eventHandler::findAll)
                GET("/{id}", eventHandler::findOne)

Reactive Programming Model:-

Spring WebFlux to be used in place of Spring MVC as a reactive model or an MVC framework. Introduced WebClient   functional and reactive API for HTTP calls, comparable to the RestTemplate  It still has Supported for Rest Template in Spring Framework 5.This seems to be one of cool Features Of Spring Framework 5.

Alon with a  @Controllerway of writing MVC, reactive way using functional endpoints is also supported in Spring WebFlux running on the reactive stack.

A  Sample WebClient implementation of a REST endpoint in Spring Framework 5 is shown below

WebClient.RequestHeadersSpec requestSpec1 = WebClient
  .body(BodyInserters.fromPublisher(Mono.just("data")), String.class);

Testing Improvements:-

Spring Framework 5 completely supports Junit5 and its extension models in the Spring TestContext Framework.

In order to test reactive web API, Spring Framework 5 provides.WebTestClient It binds to a WebFlux application using a mock request and response, or it can test any web server over an HTTP connection.We can test a particular RouterFunction by passing it to the bindToRouterFunction method.

RouterFunction function = RouterFunctions.route(
  request -> ServerResponse.ok().build()


So the limelight feature of Spring Framework 5 is reactive programming implementation.We just saw a hint of changes in Spring Framework 5. Its Will be a really exciting journey ahead with Spring Framework 5 with lot’s of a learning curve and exciting changes in upcoming days.