Interview with Stéphane Nicoll, software engineer at Pivotal

Spring 5: key features, trends and its love of reactive programming

Hartmut Schlosser
Spring 5
Stéphane Nicoll, software engineer at Pivotal

One of the biggest topics in Spring Boot 2.0 is the support for Spring 5. What does this mean in terms of features and how does Spring 5 embrace reactive programming? Stéphane Nicoll, software engineer at Pivotal answers these questions and more in anticipation of his JAX talk next week.

JAXenter: One of the big topics in Spring Boot 2.0 is the support for Spring 5. What does this mean exactly? What’s new, feature wise? 

Stéphane Nicoll: Spring Framework 5 introduces a comprehensive support for reactive programming as an alternative to the traditional blocking model based on the Servlet API. Spring Boot 2 obviously integrates those changes with a new “webflux” starter based on Netty that gives you the same getting started experience than the one you know with the web starter. Spring 5 also embraces functional programming and provides several building blocks that allow you to compose your applications. If you decide to define your router that way (rather than using annotations) we will detect that and configure the server accordingly.

A natural follow-up is to allow users to be “functional all the way” and our first-class support of the Kotlin programming language is quite natural there. Spring Boot 2 will also provide dedicated extensions for Kotlin so that you can use all the power of the language.

JAXenter: Can you give us a short example of how Spring 5 embraces reactive programming? 

Stéphane Nicoll: The Spring Framework provides a consistent model and allows you to reuse prior knowledge to new paradigms. The support of reactive programming is in no way different.

Here is a basic example of a reactive endpoint with Spring Framework 5:

public class ​SpeakerController {
  private final ​SpeakerRepository ​repository​;

  ​public ​SpeakerController(SpeakerRepository repository) {
  ​  this​.​repository ​= repository;

​public ​Mono<Speaker> getById(​@PathVariable ​String id) {
  ​return ​repository​.findOne(id).otherwiseIfEmpty(Mono.​error​(
​       new ​ResponseStatusException(HttpStatus.​NOT_FOUND​, ​"not fou,d"​)));

​public ​Flux<Speaker> getAll() { 
  return ​repository​.findAll();

​public ​Mono<Void> save(Mono<Speaker> speaker) {
  return ​repository​.save(speaker).then();

This controller is reactive end-to-end and feels quite natural to a user of the current generation. As usual, we react to method signatures and we manage the boilerplate for you. Another example is the use of our new web client that allows to easily compose several remote services invocation in a reactive fashion.

As Spring Boot is much more opinionated, a new generation allows us to revisit these opinions and rework some of them when it makes sense.

JAXenter: How is reactive programming reflected in Spring Boot 2.0?

Stéphane Nicoll: Mainly as a supporting role: if you decide to use the WebFlux stack, we will auto-configure the necessary bits the same way we do it for WebMvc today. And if you decide to use the functional route, we will detect that as well.

We have plans to rework existing components to support the reactive stack but mostly there is not going to be many user-facing changes. WebFlux will be the entry point, much like WebMvc is today.

JAXenter: What’s new in Spring Boot 2.0 apart from Spring 5 support?

Stéphane Nicoll: As Spring Boot is much more opinionated, a new generation allows us to revisit these opinions and rework some of them when it makes sense. For instance, we completely rewrote the Gradle plugin from scratch with the feedback of the community and we have heavily reworked how configuration keys are handled internally. This release is mainly about setting up firm foundations and a good base to build on.

SEE ALSO: Spring Boot – what it is and how to get started

JAXenter: What is your personal highlight in Spring Boot 2.0? And how does this highlight help developers?

Stéphane Nicoll: Supporting two different web application paradigms is quite a challenge and requires revisiting some core principles in Spring Boot. Our goal is that the ‘getting started’ experience with WebFlux is as natural as the one we have now with WebMvc, which will allow you to easily try reactive programming.

JAXenter: What is the main message of your JAX session that all visitors should take away?

Stéphane Nicoll: Reactive programming is a new choice that you can make depending on the app that you are writing. If you decide to go that route, we will accompany you throughout your journey: you’ll find a familiar programming model and Spring Boot will auto-configure the infrastructure for you. You can even go more functional later if you decide to! And of course, there is nothing wrong with building traditional MVC apps: our support for Servlet-based web stacks continues to be around as a first-class option, remaining compatible with Servlet-based technologies as well as traditional datastore interaction styles.

Thank you very much!


Stéphane Nicoll will be delivering one talk at JAX 2017 which will focus on shedding some light on Spring 5, its themes and trends.

Hartmut Schlosser
Content strategist, editor, storyteller - as online team lead at S&S Media, Hartmut is always on the lookout for the story behind the news. #java #eclipse #devops #machinelearning #seo Creative content campaigns that touch the reader make him smile. @hschlosser

Inline Feedbacks
View all comments