Spring Boot 2.0 (v2.0.0.RELEASE) is now available on GitHubClick the linkTo download. But because of the synchronization toMaven repository errorUsing Maven to use Spring Boot 2.0 is temporarily problematic.

As a major open source project in the Spring ecosystem, Spring Boot aims to simplify the creation of production-level Spring applications and services. Users only need to “run “to create a stand-alone, production-level Spring application. It has been nearly a year since the release of the M1 version on 16 May last year, then the RC version, and now the official release of Spring Boot 2.0.

Let’s take a look at what new features Spring Boot 2.0 has introduced. Support for Java 9, HTTP/2, Build on Spring 5, strong integration with GSON, and more.

The Spring and Spring to Boot

In March 2004, the first release of Spring and founder Rod Johnson’s classic, Expert One-to-one J2EE Development Without EJB, were released, Breaking the traditional thinking mode in the field of Java development at that time, enterprise applications began to “lightweight” development pace.

The original Spring Framework 1.0 was not as complex as Spring is today, but it did include two of the most core elements of Spring: Dependency injection (IOC) and aspect oriented programming (AOP) are key features that set Spring apart from other excellent frameworks and establish it as a core feature in enterprise applications.

Many developers when entering the Java application is likely to feel the meaning of these two functions is not big, because without them, we still can be good business functions, it is, but with the deepening of the iteration and development business, complex and changeable demand began to slowly erode the architecture of the “perfect” originally, the difficulty of the development and testing increases gradually, This is often when we realize the value of Spring.

So, even if in the original version of the Spring also encapsulates many partial YeWuXing function encapsulation, such as email, transaction management, etc., but we need to know to make the enterprise applications without Spring is not real these is directly related to business functions, but had nothing to do with business implementation of the above mentioned two core.

Because in the early version of Spring, many functional packages are not as powerful as today’s Spring, so for a long time, we have adopted Spring for project management to integrate other better functional frameworks to complete the architecture mode of system development. For example, the once-popular Spring + Struts + Hibernate architecture can bring back memories of a generation.

However, with the release of Spring 2.0, Spring began to support the elegant configuration of annotations and the more flexible configuration of Java classes, leading to a greater diversity in the way that Spring manages Bean configurations.

In addition to Java 8 support and dependency injection enhancements in Spring 4.x, for a long time the Spring community was less innovative with its core framework, and more of the community’s energy began to be directed towards its once-close friends. As a result, we found a variety of functional sibling projects in the Spring community, such as Spring Data, which simplifies Data access, Spring Batch, which provides Batch processing capabilities, and Spring Security, which protects application Security.

Although these frames from individuals has certain advantages and advanced concept, but for many existing system, it is difficult to make changes in the functional framework, for these are difficult to get the wheels of the new project application, besides some will try to do some system from scratch, given the learning cost and risk consideration on pit, Few small and medium-sized teams are willing to try these new projects. As a result, some older functional frameworks are hard to replace with these wheels unless there are serious performance or security issues.

However, the Spring community welcomed Spring Boot on April 1, 2014, with its first official release. This project is designed to make it easier for developers to create Spring-based applications and services, enabling existing and new Spring developers to get their Spring functionality as quickly as possible. Today, nearly four years after the 2.x release, Spring Boot is a popular open source project with over 21,000 Commits, 15,000 Commits, and over 400 contributors.

Using Spring Boot for development can greatly save development time and improve development efficiency. It has the following characteristics:

  • Simplify dependency management: Spring Boot provides a series of Starter POMs, which divide and package various functional modules, making it easier to introduce and use, and effectively avoiding JAR conflicts caused by maintaining a large number of dependencies when users build traditional Spring applications.
  • Automated configuration: Spring Boot provides automated Java configuration classes for every Starter to replace the tedious and not very variable Bean configuration in our traditional Spring applications in XML; With a series of conditional annotations, we can easily replace these automatically configured beans for extension.
  • Embedded containers: In addition to the optimization of code organization, the support for embedded containers in Spring Boot is a big plus, making packaging and running Spring Boot applications very lightweight.
  • Production-level monitoring endpoint: Spring-boot-starter – Actuator launch can be said to be another important innovation of Spring Boot based on Spring, which becomes more perfect for the engineering of Spring applications. This module does not help us to achieve any business functions, but it gives us more support in architecture operation and maintenance. Through the HTTP interface exposed by this module, we can easily understand and control the operation of Spring Boot applications.

It can be said that although Spring Boot is built on Spring, it changes the way we use Spring, greatly simplifies the configuration work of building enterprise applications, and makes it easier to get started, especially for many beginners.

New features in Spring Boot 2.0

A preview of Spring Boot 2.0 provides a glimpse of what changes Spring Boot 2.0 will bring compared to previous releases. As previously reported, the biggest changes to Spring Boot 2.0 focus on the following areas:

  • Spring Boot 2.0 is based on Spring Framework 5, and the entire Spring Framework 5.0 code base runs on Top of Java 8. As a result, Spring Boot 2.0 requires a minimum JDK version of Java 8, and Java 9 is officially supported.
  • The difference from Spring Boot 1 is that many configuration properties have been renamed or removed, so migration from Spring Boot 1 to Spring Boot 2 requires attention to these configuration properties.
  • The key innovation Spring Boot introduces to Java applications is embedding the Servlet container into an executable JAR package that packages the entire application. Spring Boot also offers Tomcat, Undertow, and Jetty as options.

In addition, there are many other exciting new features in Spring Boot 2.0, such as: Support for HTTP/2, a more flexible property binding API, simplified configuration for Spring Security integration, enhancements to the Gradle plugin, and optimization of the Actuator module.

In previous RC releases, Tomcat, Undertow, and Jetty all support HTTP/2 (Hypertext Transfer Protocol 2.0) and provide support for native TLS through the Conscrypt library. This is significant for Tomcat 8.5.x, the default server for Spring Boot, and only HTTP/2 is supported if the libtcnative library and its dependencies are installed on the host operating system.

On the monitoring side, Spring Boot 2 offers enhanced integration with Micrometer. RabbitMQ, JVM threads, and garbage collection metrics are automatically monitored by instrument, and asynchronous controllers are automatically added to the monitoring. After integration, you can also monitor the InfluxDB servers.

On the data side, Spring Boot 2 lets you customize Hibernate properties in a more fine-grained way. In addition, you can control the Redisc Server by exposing a Redisc Server Configuration. Flyway and Liquibase configurations are also more flexible.

In addition, Spring Boot 2 has greatly enhanced SUPPORT for GSON and includes an improved Actuator JSON architecture. In addition, there are many new features, readers can understand the details by the following address: www.oschina.net/translate/s… .

Support Java 9

The most anticipated new feature of Spring Boot 2.0 is the formal support for Java 9. The minimum JDK version required now is Java 8, which means you cannot run Spring Boot 2.0 using JDK 7 or older.

It’s worth noting that the current version of Spring Boot 2.0, while supporting Java 9, still has some issues. For example, JDK proxy support requires AspectJ 1.9, but that version is still in RC; Apache Cassandra is not supported yet; JSP TLDs are also not supported in embedded Tomcat. Running Spring Boot on Java 9: github.com/spring-proj…

Spring Framework

Spring Framework 5.0 is now integrated with Spring Boot. Spring Framework 5.0 has some interesting features:

  • Support for JDK 9 and Java EE 8 level apis such as Servlet 4.0;
  • Full integration with Reactor 3.1, JUnit 5, and Kotlin languages;
  • Will bring many functional API variants;
  • Spring WebFlux, a responsive stack Web framework;
  • JUnit 5 Jupiter is fully supported, so tests can be written in JUnit 5;
  • Added support for @nullable and @notnull annotations to handle null pointer exceptions at compile time rather than run time.

Spring Security

Spring Security is not an official part of Spring Boot, but it’s worth mentioning here because it works well with Spring Framework 5.0. The latest Release of Spring Security 5 offers more than 400 feature enhancements and bug fixes. These new features include:

  • Users can use the OAuth 2.0 Provider to authenticate with an existing account.
  • Like Spring Framework 5, Spring Security 5 adds support for responsive programming;
  • Encoding passwords in a more modern way.

WebFlux and webflux.fn are supported

Spring Boot 2.0 provides a new initiator — Spring-boot-starter -webflux for the responsive Spring Web framework. Spring-boot-starter -webflux itself includes webFlux. Plus Reactor Netty as the default Web engine (Spring-boot-starter-netTY).

Responsive controllers can be tested using @WebFluxTest, which provides support similar to @WebMVcTest for Spring MVC, and WebTestClient is automatically configured.

Dependent component update

The Starter of Spring Boot integrates many excellent third-party components. The upgrade of these components also needs to be considered. In the upgrade process of these components, whether there are changes in the use and other issues. Among them, the most critical components need our attention:

Tomcat (8.5.28) Flyway (5) Hibernate (5.2) Thymeleaf (3

Spring Boot 2.0 (8.5.28) is a secure version of Spring Boot 2.0.

Thymeleaf

Another notable new feature of Spring Boot 2 is that Thymeleaf 3 is now officially supported, including updates to Thymeleaf and Spring Security Thymeleaf dependencies. Notable changes in Thymeleaf 3:

  • Thanks to a new parsing system, Thymeleaf is no longer XML based;
  • Introduced a new text template pattern, which gives Thymeleaf the ability to output CSS, Javascript, and plain text;
  • Rewrote engine, improved performance significantly.

Note: Spring Boot 2.0 is officially released and new features are interpreted