days
-1
-8
hours
-1
-9
minutes
-1
-3
seconds
-3
-1
search

Spring Boot 2 – An overview: All those “little” updates and improvements

Michael Simons
© Shutterstock.com / Igor Bukhlin

Upgrades to the latest version of supported libraries and tools, enhancements through and with Spring Framework 5, and changes to the heart of Spring Boot. The second major release of Spring Boot leaves no stone unturned. The last part of this series focuses on some “minor” changes and improvements in Spring Boot 2.

Michael Simons is a speaker at JAX 2018 and author of the book “Spring Boot – Moderne Softwareentwicklung im Spring Ökosystem“, published by dpunkt.verlag.

Java 8 baseline and Java 9+ support

Spring Boot 2 is based on the Spring Framework 5 and therefore requires Java 8. Conversely, this signifies that Spring Boot 2 cannot run on Java 7 or older versions of the programming language. Spring Framework 5 is fully compatible with Java Development Kit 9 (JDK 9), both in development and deployment, and works on both the class and module paths.

But what about Jakarta EE / Java EE?

Spring Framework 5 requires the Java EE 7 API and supports the Java EE 8 API at runtime. This means that at least Tomcat 8.5, Jetty 9.4 or WildFly 10 are required. Servlet 4, Validation 2.0, JPA 2.2 and JSON Binding 1.0 are also supported and have been tested extensively.

Spring Framework 5

Upgrading to Spring Framework 5 removes several deprecated classes and features including Hibernate 3 and 5, Tiles 3, Portlet, Velocity, JasperReports, XMLBeans, JDO and Guava in particular. If your application relies on one or more of these features, better stick to the Spring Boot 1.5.x release cycle. Furthermore, Spring Framework 5 brings new features: interfaces are consistently annotated with Nullable or NotNullable and the core container supports functional bean registration (the 4th possibility to build components according to XML, annotations and the explicit Java configuration).

Updated Web MVC and a completely revamped WebFlux

I already presented the new WebFlux module in detail, but the Web MVC was also updated: It supports the Servlet 4.0 specification, is now independent of the Java Activation Framework, can bind immutable objects and much more.

Kotlin support

Spring Framework 5 has first-class support for Kotlin based on a domain-specific language (DSL). It is used to configure the application context, to route WebFlux and for a multitude of adaptations regarding language features. These features include reified types to avoid constant casting.

JUnit 5

While Spring Boot 2 still uses JUnit 4 for testing by default, it fully supports the JUnit Jupiter platform via Spring Framework 5 and provides SpringExtension, @SpringJUnitConfig and more. Plus: If you want to annoy your colleagues, you may make use of @EnabledIf or @DisabledIf on the CI server.

Further notable updates

Major updates of the following dependencies have also been applied:

  • Thymeleaf 3 is now not only supported, but default. This can result in some work if your application uses its own dialects.
  • Flyway is now used in version 5.
  • The update to Hibernate 5.2 will force you to take another look at your entity mapping code.

Changes in Spring Boot 2

  • @ConfigurationProperties are only validated if they are marked as @Validated.
  • The binding mechanism has been completely rewritten and can be used in a trivial way if you want to test and bind properties very early as part of a starter.
  • All properties, packages and classes used in the context of an embedded servlet container have been restructured and now reflect the dualism of Spring Web MVC and WebFlux.
  • There is a practical new starter: spring-boot-starter-json. This will load and register all libraries Json needs to process Java-8 data types.
  • Spring Boot now uses HikariCP as the default pool for database connections.
  • If Hibernate is used in combination with an embedded database, spring.jpa.hibernate.ddl-auto is only set to create-drop if no schema manager like Flyway or Liquibase is involved.
  • Custom starters are affected by a small but important change: @ConditionalOnBean now uses AND instead of OR to link multiple, specified beans.

Conclusion

A Hello World application will easily be migrated. In most cases, however, applications in the real world consist of more than one endpoint. The numerous upgrades of upstream libraries alone should be treated with caution.

There is nothing wrong with setting up new services using Spring Boot 2. It has now been in development for over a year and as the author of a book on the subject, it was an interesting experience to accompany this development. However, an existing application should not be updated simply by changing a version number in the build file.

As a reward for upgrading, there are reactive applications, modern platforms and last but not least: animated banners (see Tweet). So now I know which topic I can take up as an example for my own starters in 2018.

Spring Boot – Modern software development within the Spring ecosystem
The Spring Boot book will be published in late April 2018 and will cover all current topics related to Spring Boot 2. In addition to the reactive programming model with Spring 5, this includes the new actuator infrastructure, Micrometer.io support and much more. This book is intended to appeal to interested developers from the Java EE area as well as Spring developers and give them a “recipe” to handle recurring tasks from everyday business life elegantly and without distraction using Spring Boot.

Further information on the book can be found here!

Author
spring boot

Michael Simons

Michael Simons works as a Senior Consultant at innoQ Germany. He is a member of the NetBeans Dream Team and founder of the Euregio JUG. Michael writes on his blog about Java, Spring and software architecture. He is on Twitter as @rotnroll666, where he deals with Java, music and minor and major problems as a husband and father of two children. In January 2018 Michael’s book “Spring Boot — Moderne Softwareentwicklung im Spring-Ökosystem” will be published by dpunkt.verlag. The book can already be pre-ordered at springbootbuch.de. It covers Spring Boot 2 and the new, reactive programming paradigm of Spring 5 as well as Spring basics and thus appeals to experienced Spring developers as well as new beginners. The diagrams in this article are also from the book, as are some of the examples shown. The code is already available on GitHub.


Leave a Reply

Be the First to Comment!

avatar
400
  Subscribe  
Notify of