Spring Boot 2.0 New Features: Infrastructure Changes
In my previous post, Spring Boot 2.0 New Features: The 3 Most Important Changes You Must Know About, I pointed out the one of the notable changes coming with Spring Boot 2 will be infrastructure updates. This post enumerates these updates so that you can see their impact once before you would upgrade.
Spring Boot 2 baseline changes
Java 8 Baseline
Releasing a new major version gave the Spring team the opportunity to rebase the codebase upon Java 8 and use its new features. Therefore Spring Boot 2.0 requires Java 8 or later, consequently it doesn’t support Java 6 and Java 7 any more, because they reached their end of life anyway.
Java 9 Support
Spring Boot 2 fully supports it and there is a dedicated page Spring Boot with Java 9 that provides more details if you want to run Spring Boot apps with Java 9.
Spring Framework 5.0
Spring Boot 2.0 builds on and requires Spring Framework 5.0. Altought Spring 5 has been generally available since September of 2017, probably most projects will start to adapt it when Spring Boot 2.0 hits GA. Spring 5 introduces a number of nice refinements as well and one of the most noteworthy of its new features is its extensive support for building reactive applications in a next post.
Embedded Servlet Containers
The minimum supported version of Jetty is 9.4.
The minimum supported version of Tomcat is 8.5
You can configure SSL for your WebFlux application with
server.ssl.* configuration properties and all available servers (Tomcat, Jetty, Undertow and Reactor Netty) supports this configuration.
Maven projects are compiled with the
-parameters compiler flag by default.
Spring Boot requires Gradle 4.x. Spring Boot’s Gradle plugin has been largely rewritten to enable a number of significant improvements. You can read more about the plugin’s capabilities in its reference and api documentation.
BootRun task provides properties for configuring the application’s arguments (
args) and JVM arguments (
jvmArgs) and more advanced configuration is available via
execSpec. See the Gradle plugin’s documentation for more details. Based on user feedback, the
BootRun task is once again a subclass of Gradle’s
JavaExec task. It can be configured in the same way as any other
JDBC / ORM changes
Default connection pool
The default connection pool has changed from Tomcat to HikariCP. If you are using Hikari in an environment where
tomcat-jdbc is provided, you can remove the
spring.datasource.typeoverride. Similarly, if you want to stay with the Tomcat connection pool, simply add the following to your configuration:
Liquibase and Flyway configuration keys were moved to the
spring namespace (i.e.
Flyway/Liquibase flexible configuration
If only a custom
user is provided, the auto-configuration reuses the standard datasource properties rather than ignoring them. This allows you to create a custom
DataSource for the purpose of the migration with only the required information.
Detection of DataSource initialization
If Flyway or Liquibase is managing the schema of your
DataSource and you’re using an embedded database, Spring Boot 2 will automatically switch off Hibernate’s automatic DDL feature.
Database initialization for Spring Batch, Spring Integration, Spring Session and Quartz occurs by default only when using and embedded database. The
enabled property has been replaced with a more expressive enum. For example, if you want to always perform Spring Batch initialization you can set
DataSource initialization is only enabled for embedded data sources and will switch off as soon as you’re using a production database. Furthermore the new
spring.datasource.initialize) offers more control.
Data Sources Metrics
Instrumentation takes care of monitoring all available data sources and publishes metrics (min, max and usage) metrics for each.
Configurable JPA mapping resources
If you were extending Spring Boot’s JPA configuration to register mapping resources, there is a
JdbcTemplate that Spring Boot auto-configures can be customized via the
spring.jdbc.template namespace. Also, the
NamedParameterJdbcTemplate that is auto-configured reuses the
JdbcTemplate behind the scenes.
Spring Boot detects the jOOQ dialect automatically based on the
DataSource (similarly to what is done for the JPA dialect). Also a
@JooqTest has been introduced to ease testing where only jOOQ has to be used.
The minimum supported version of Hibernate is 5.2. Read Hibernate 5.2 Migration Guide to find out how to upgrade.
Support for custom Hibernate naming strategies
For advanced scenario, you can define the
PhysicalNamingStrategy to use as regular beans in the context.
Hibernate properties customization
It is possible to customize the
properties Hibernate uses in a more fine grained way by exposing a
spring.data.cassandra exposes pooling options.
Reactive Couchbase support
Support for Spring Data reactive repositories is available for Couchbase and a
spring-boot-starter-data-couchbase-reactive is available to easily get started.
If the InfluxDB java client and the
spring.influx.url is set, an
InfluxDB client is automatically configured. Support for credentials is available as well. The
health endpoint can monitor an
Redis cache configuration
It is possible to expose a
RedisCacheConfiguration to take control over the
RedisCacheManager. A new annotation
@DataRedisTesthas also been introduced.
Spring Boot 2 requires Elasticsearch 5.4 from now on. In line with Elastic’s announcement that embedded Elasticsearch is no longer supported, auto-configuration of a
NodeClient has been removed. A
TransportClient can be auto-configured by using
spring.data.elasticsearch.cluster-nodesto provide the addresses of one or more nodes to connect to.
Mongo client customizations
It is possible to apply advanced customizations to the MongoDB client that Spring Boot auto-configures by defining a bean of type
Mockito 1.x is no longer supported for
@SpyBean. If you don’t use
spring-boot-starter-test to manage your dependencies you should upgrade to Mockito 2.x.
Kotlin extensions for
RestTemplate extensions are also available for
TestRestTemplate to make the developer experience consistent.
GenericConverter beans are automatically scanned with
Reference: Spring Boot 2.0 Release Notes