Based on Java 8
Spring Boot 2.0 requires Java version 8 or higher, and Java 6 and 7 are no longer supported.
Inline container package structure adjustment
In order to support reactive usage scenarios, the embedded container package structure has been refactored to a large extent. EmbeddedServletContainer was renamed to WebServer, and the org.springframework.boot.context.embedded package was redirected to the org.springframework.boot.web.embedded package. For example, if you want to use the TomcatEmbeddedServletContainerFactory callback interface to customize the embedded Tomcat container, you should now use the TomcatServletWebServerFactory.
Servlet-specific server properties tuning
A number of servlet-specific server.* properties have been moved under server.servlet:
From this, we can see some clues, that is, the server is no longer only servlet, there are other to join.
Actuator default mapping
Actuator endpoints are now mapped to /application by default, for example, the /info endpoint is now /application/info. But you can use management.context-path to override this default.
@ConditionalOnBean
The judgment condition of @ConditionalOnBean is now changed from OR to AND.
Remote CRaSH shell
In 1.5, this remote tool was marked as deprecated. In 2.0, this support will be completely removed, and projects based on this feature will also be removed.
Spring Loaded is no longer supported
Since the Spring Loaded project has been moved to attic, Spring Loaded is no longer supported. It is now recommended that you use Devtools. Spring Loaded is no longer supported.
Hazelcast auto-configuration is no longer supported
HazelcastInstance can no longer be automatically configured for caching. Therefore, the spring.cache.hazelcast.config property is no longer available.
The default connection pool has changed
The default connection pool has been switched from Tomcat to HikariCP. If you used spring.datasource.type to force Hikari in Tomcat based applications in the past, now you can remove this override. Similarly, if you want to use Tomcat's connection pool, you only need to simply add the following configuration:
spring.datasource.type=org.apache.tomcat.jdbc.pool.DataSource
Servlet Filters
The default dispatcher type for a Filter is now DispatcherType.REQUEST, which ensures that the default configuration of Spring Boot and Servlet is unified.
Spring Security
Spring Security's filters can now be auto-configured for the following types: ASYNC, ERROR, and REQUEST . This makes the configuration in Spring Boot consistent with the Spring Security default configuration.
Spring Session
Spring Session's filter now supports auto-configuration of the following dispatcher types ASYNC, ERROR, and REQUEST. The same is to keep Spring Boot's configuration consistent with Spring Session's default configuration. It is worth noting that as of Spring Session 2.0, Mongo and GemFire will no longer be supported.
Jetty
Jetty minimum version 9.4 is required.
Tomcat
Tomcat minimum version 8.5 is required.
Hibernate
Requires a minimum version of Hibernate 5.2.
Gradle
Minimum Gradle version 3.4 is required.
SendGrid
The minimum supported version of SendGrid is 3.2. To support this upgrade, username and password have been removed. Because API key is now the only supported authentication method.
Changes to Starter's transitive dependencies
Several Spring Boot starters used to rely on Spring MVC and spring-boot-starter-web delivery. For Spring WebFlux support, spring-boot-starter-mustache and spring-boot-starter-thymeleaf no longer depend on spring-boot-starter-web. Now you have to choose and add spring-boot-starter-web or spring-boot-starter-webflux as a dependency.
Solr Health Metrics
The health check information for Solr is no longer an attribute of solrStatus. It is now the status property, a standard status property that corresponds to an integer value.
Default proxy policy
Spring Boot now defaults to using a CGLIB proxy, which also includes AOP support. If you need a proxy-based proxy strategy, you need to set spring.aop.proxy-target-class to false.
CLI based tests
Testing support has been removed from Spring Boot's CLI, and it is now recommended that you build your application with Maven or Gradle to take advantage of the rich testing support they provide.
@ConfigurationProperties
The ignoreNestedProperties property in @ConfigurationProperties has been removed.
Multipart configuration changes
The spring.http.multipart. property has been named spring.servlet.multipart to better reflect the Servlet features.
ps: In fact, because webflux is here, only servlet and webflux can be distinguished.
Mustache template default file extension
The default file extension for Mustache templates used to be .html. Now .mustache is the official extension, and many IDE plugins already support this extension. You can override the current default support via spring.mustache.suffix.
Spring Framework 5.0
Spring Boot 2.0 is built on top of Spring Framework 5.0 (minimum requirement). The biggest highlight of Spring 5 is reactive.
loose binding improvement
Loose binding has been improved. Here is a simple example:
Simple properties are bound after removing special characters and converting to lowercase. for example:
The following properties will eventually be mapped to spring.jpa.databaseplatform=mysql:
spring.jpa.database-platform=mysql
spring.jpa.databasePlatform=mysql
spring.JPA.database_platform=mysql
For details, we can consult: https://github.com/spring-projects/spring-boot/wiki/Relaxed-Binding-2.0
WebFlux and WebFlux.fn support
Spring Boot 2.0 provides a new starter to support Reactive Spring web frameworks. The starter is spring-boot-starter-webflux. Where Reactor Netty is the default web engine (spring-boot-starter-reactor-netty).
Reactive database support
Spring Boot 2.0 provides auto-configuration reactive support for the following databases:
-
MongoDB (spring-boot-starter-data-mongodb-reactive)
-
Redis (spring-boot-starter-data-redis-reactive)
-
Cassandra (spring-boot-starter-data-cassandra-reactive)
The @DataMongoTest test annotation is also reactive.
@WebFluxTest support
Reactive controllers can now be tested using @WebFluxTest. It provides functionality similar to @WebMvcTest. And WebTestClient can be used directly and has been auto-configured.
Supports auto-configuration of WebTestClient using @SpringBootTest
当你使用 @SpringBootTest with an actual server (that is, either DEFINEDPORT or RANDOMPORT), a WebTestClient is available the same way TestRestTemplate is.
WebTestClient auto-configuration with @SpringBootTest
When using @SpringBootTest with an actual server (ie DEFINED PORT or RANDOM PORT), WebTestClient is available in the same way as TestRestTemplate.
Gradle plugin
The Gradle plugin for Spring Boot has been largely rewritten to implement some major improvements. I won't go into details about this, and interested students can go and find out.
Status code change for /loggers endpoint POST
The status code for POST operations on the /loggers endpoint has been changed from 200 to 204.
Elasticsearch
Elasticsearch has been upgraded to 5.4. As with the announcement from Elastic that embedded Elasticsearch is no longer supported, the automatic configuration of NodeClient has been removed. It's the same rhythm. Now you can auto-configure the TransportClient by using spring.data.elasticsearch.cluster-nodes , where the value can be the address of one or more nodes to connect to.
Quartz Scheduler
Spring Boot 2 provides support for the Quartz scheduler. You can add spring-boot-starter-quartz starter to enable. And supports both memory-based and jdbc-based storage.
Spring Data Web Configuration
Spring Boot exposes a new spring.data.web configuration namespace that makes it easy to configure paging and sorting.
Json starter
A brand new spring-boot-starter-json starter aggregates many commonly used json tools and can support reading and writing json.
It provides not only jackson-databind but also useful modules when you use java8: jackson-datatype-jdk8, jackson-datatype-jsr310 and jackson-module-parameter-names.
This new starter can be used where jackson-databind was used before.
Thymeleaf starter
Thymeleaf starter now includes thymeleaf-extras-java8time out of the box.
InfluxDB
An InfluxDB client is now automatically configured if the InfluxDB java client and the spring.influx.url are set. And now supports authentication.
JdbcTemplate
Spring Boot's auto-configured JdbcTemplate can now be customized via the spring.jdbc.template namespace. In addition, the auto-configured NamedParameterJdbcTemplate is the JdbcTemplate under the hood.
jOOQ
Spring Boot can now automatically detect the jOOQ dialect (similar to the JPA dialect) based on the DataSource.
In addition, @JooqTest is introduced for test scenarios that only jOOQ can hold.
@DataRedisTest
Added a new annotation for redis when testing.
Powerful Mongo client customization
Spring Boot's Mongo client can now be highly customized through the MongoClientSettingsBuilderCustomizer bean.
Cassandra
spring.data.cassandra now supports pooling.
Kafka listener supports batch consumption
Now supports the consumption of multiple ConsumerRecords in batches at one time, you can create a batch of listeners (listener), set as follows:
spring.kafka.listener.type=batch
Web filters initialization
Web filters are now instantiated in all supported containers. That is eagerly, eager loading.
Auto-configuration report
Classes that do not meet the conditions (unconditional) are now included and returned in the response of the auto-configuration Actuator endpoint.
reset logger action
The Loggers endpoint now supports resetting the log level to the default setting.
Maven plugin properties
The configuration properties of plugins are now exposed differently, everything is now prefixed with spring-boot, this is to avoid conflicts with other plugins and cause errors.
For example, the following command line enables profile foo:
mvn spring-boot:run -Dspring-boot.run.profiles=foo
Devtools remote debugging
Support for remote debugging over HTTP has been removed from Devtools. (#9489)
Jetty
In order to align with Tomcat and Undertow, all Jetty http method requests are now compressed, instead of only GET requests as before (#8184).
Reactive server customization
Customizers for Jetty, Tomcat, Undertow are now called when configuring a reactive web server (#9572).
Jolokia
Jolokia is no longer an endpoint. And it is disabled by default, which has remained with other web endpoints. Its configuration has been moved to management.jolokia. To enable Jolokia, add management.jolokia.enabled=true to your configuration.
database migration
Liquibase and Flyway configuration keys have been moved to the spring namespace: (eg: spring.liquibase and spring.flyway ).
Auto-configuration sorting
@AutoConfigureOrder default value changed from Ordered.LOWEST_PRECEDENCE to 0. (#10142)
Auto-configuration test tool
A new ApplicationContextRunner testing tool makes it easy to test auto-configuration. All test suites will be migrated to this model in the future.
Java 9 support
Java 9 is basically supported. It is "basic" because it has not been authenticated by the user.
Jedis becomes Lettuce
The Redis client driver is now Lettuce from Jedis. Students who use Jedis probably know the direction.
But still supports Jedis, then exclude io.lettuce:lettuce-core, and then add redis.clients:jedis.
OAuth 2.0 support
Features from the Spring Security OAuth project will be migrated to Spring Security. Will be OAuth 2.0.
Mockito 1.x
Mockito 1.x no longer supports @MockBean and @SpyBean. If you are not using spring-boot-starter-test to manage dependencies, you should upgrade to Mockito 2.x.
JSON-B support
In addition to Jackson and Gson, JSON-B is now supported. JSON testing support has also been updated with the new JsonbTester class.
Session Endpoint
Spring Session users can now find and delete sessions through the /application/sessions Actuator Endpoint.
ConfigurationProperties validation
If you want to enable validation on the @ConfigurationProperties object, just add @Validated.
Spring Mobile
Auto-configuration and dependencies for Spring Mobile are no longer supported and have been removed.
Spring WebFlux supports error conventions
Spring Boot now aligns WebFlux's error conventions with MVC just like using MVC: default views and JSON response errors, custom error views, and more.
TLS configuration and HTTP/2 support
You can now configure SSL for your WebFlux application using the server.ssl.* configuration properties. Tomcat, Jetty, Undertow and Reactor Netty are all supported.
You can now also configure HTTP/2 for your MVC or WebFlux application:
使用 server.http2.enabled。
@KafkaListener supports using @SendTo
Kafka listeners using auto-configuration factories now support @SendTo.
Kotlin extension
Spring Boot 2.0 released the Kotlin runApplication extension:
package com.example.demo
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
@SpringBootApplication
class DemoApplication
fun main(args: Array) {
runApplication(*args)
}
Job command line runner sequence
CommandLineRunner now executes batch jobs with a start order of 0.
Templated welcome page with auto-configuration
Spring Boot 2.0 now supports both static and templated welcome page types. It will first look for the index.html file in the configured static content directory, if not, then look for the index template. Whenever one is found, it will be used as the welcome page.
Context path will be printed on startup
In previous versions of Spring Boot, the context path didn't seem to be given that much attention. Now when we use the inline container, the context path will be printed next to the HTTP port, like this:
Tomcat started on port(s): 8080 (http) with context path ‘/foo’
Test optimization, automatic scanning Converter and GenericConverter
Converter and GenericConverter beans are now automatically scanned by @WebMvcTest and @WebFluxTest.
Health vs. Status
The status endpoint has been removed and is now health. The health endpoint can either display the status or have more details. The health endpoint is now exposed by default (only status is shown). If you want to show more details, you can do so by modifying the property management.endpoints.health.show-details:
management.endpoints.health.show-details=true