Overview of new features in Spring Boot 2: Official support for Java 9

According to our previous reports, the biggest changes in Spring Boot 2 are mainly concentrated in the following aspects:

First, Spring Boot 2 is based on Spring Framework 5, and the entire Spring Framework 5.0 codebase runs on Java 8. Therefore, the minimum JDK version required by Spring Boot 2 is Java 8, and Java 9 has been officially supported (here is a document for running Spring Boot with Java 9 https://www.oschina.net/translate/spring-boot-with -java9)

Second, the difference with Spring Boot 1 is that many configuration properties have been renamed or deleted, so some configuration properties need to be paid attention to when migrating from Spring Boot 1 to Spring Boot 2

Third , the key that Spring Boot introduces for Java applications The innovation is to embed the servlet container into an executable jar that packages the entire application. Spring Boot also provides Tomcat, Undertow, and Jetty as optional solutions.

In previous RC releases, Tomcat, Undertow, and Jetty already support HTTP/2 and provide native TLS support through the Conscrypt library. This is significant for Spring Boot's default server, Tomcat 8.5.x, which only supports HTTP/2 if the libtcnative library and its dependencies are installed on the host OS.

For monitoring, Spring Boot 2 has enhanced integration with Micrometer. RabbitMQ, JVM threads and garbage collection metrics are automatically monitored for instrumentation, and asynchronous controllers are automatically added to the monitoring. Through the integration, monitoring of the InfluxDB server is also possible.

On the data side, Spring Boot 2 lets you customize Hibernate properties in a more granular way. In addition, RedisCacheConfiguration can be exposed to control RedisCacheManager. Flyway and Liquibase configuration are also more flexible.

In addition, Spring Boot 2 has greatly enhanced support for GSON and includes an improved actuator JSON schema.

Another notable change is the Spring Boot banner - an ASCII image at startup that is widely used by development teams to display their application branding. In Spring Boot 2, animated GIFs are now supported.


It's worth noting that in Spring Boot 2.0, many configuration properties have been renamed or removed, and to facilitate upgrades, Spring Boot has released a new spring-boot-properties-migrator module. Just add it to your project as a dependency, and it will not only analyze your application's environment and print diagnostics at startup, but will also temporarily migrate properties to the new configuration for your project during the runtime phase.


For a more detailed migration guide for Spring Boot 2.0, stay tuned to the official documentation we are translating. (https://www.oschina.net/translate/spring-boot-2-0-migration-guide)
Interested developers are welcome to participate in the translation~!

Let's take a look at the new features of Spring Boot 2 worth noting.

Support for Java 9
Spring Boot 2's most anticipated new feature is official support for Java 9, which now requires a minimum JDK version of Java 8, which means that Spring Boot 2 cannot be run with JDK 7 or older.

Spring Framework
Spring Framework 5.0 is now integrated with Spring Boot. Some interesting features of Spring Framework 5.0:

1. Support for JDK 9 and Java EE 8 level APIs (such as Servlet 4.0)

2. Full integration with Reactor 3.1, JUnit 5, and Kotlin language

3. Bringing many functional API changes (functional API variants)

4. Responsive stack web framework - Spring WebFlux

5. Fully supports JUnit 5 Jupiter, so you can write tests in JUnit 5

6. Add support for @Nullable and @NotNull annotations to Compile-time rather than runtime handling of null pointer exceptions

Spring Security
Although Spring Security is not officially part of Spring Boot, it is worth mentioning here because it works well with Spring Framework 5.0. The latest Spring Security 5 offers over 400 feature enhancements and bug fixes. There are the following new features worth noting:

1. Users can authenticate with existing accounts through OAuth 2.0 providers

2. Like Spring Framework 5, Spring Security 5 also adds support for reactive programming

3. Complete the encoding of passwords in a more modern way

@ConditionalOnBean
An important thing to consider when migrating from Spring Boot 1.x to 2.x is that the @ConditionalOnBean annotation now uses a logical AND instead of a logical OR when determining if a condition is met.

Support for WebFlux and WebFlux.fn
Spring Boot 2.0 provides a new starter for the responsive Spring Web Framework - spring-boot-starter-webflux, spring-boot-starter-webflux itself contains WebFlux, plus Reactor Netty as the default web engine (spring-boot-starter-reactor-netty).

Reactive controllers can be tested using @WebFluxTest, which provides Spring MVC-like support for @WebMvcTest, and the WebTestClient is auto-configured.

Updates to dependent components -
Jetty 9.4

- Tomcat 8.5 -

Hibernate 5.2

- Gradle 3.4

Thymeleaf
Another interesting 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:

1. Thymeleaf is no longer based on XML due to the use of a new parsing system.

2. A new text template mode is introduced, which provides Thymeleaf with the ability to output CSS, Javascript and plain text.

3. Rewrite

Finally ,
Spring Boot 2 is a major version. The following new features may be the reason why you choose to upgrade:

1. Support Java 9

2. Better support for responsive applications

3. Support Thymeleaf 3

If You can benefit from these changes and consider upgrading. Also, Spring Boot 2 includes many bug fixes and performance improvements that are great reasons to upgrade.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325857910&siteId=291194637