Spring Boot 2.0 Features

Spring Boot 2.0 Features thumbnail
10K
By Dhiraj 18 May, 2017
spring-boot-2.0

The first milestone of Spring Boot 2 has just got released this month and in this article we will point out different new features, enhancements and deprecations introduced in spring boot 2.0 along with the java version support, jetty and tomcat support, hibernate support and many more. So, let us get started.

System Requirements

Spring Boot 2 requires a minimum of java 8 and Spring Framework 5 as a baseline to get started and hence it provides extensive support for building reactive applications. The different embedded servlet containers that are supported out of the box are Tomcat 8.5, Jetty 9.4 and Undertow 1.3.. The minimum supported version of Hibernate is 5.2. Also, the minimum supported version of Gradle is raised to 3.4.All the deprecated classes, methods and properties in Spring Boot 1.5 has been removed from this release.

Spring Security

In this release Spring Security’s filter is now auto-configured with ASYNC, ERROR, and REQUEST dispatcher types. This aligns Spring Boot’s default configuration with Spring Security’s default configuration.

Spring Session

Spring Session’s filter is now auto-configured with ASYNC, ERROR, and REQUEST dispatcher types. This aligns Spring Boot’s default configuration with Spring Session’s default configuration.

Multipart configuration

To better reflect their Servlet-specific nature, the multipart spring.http.multipart. configuration properties have been renamed to spring.servlet.multipart..

@ConditionalOnBean

@ConditionalOnBean now uses a logical AND rather than a logical OR when determining whether or not the condition has been met.

CRaSH

No support for the CRaSH remote shell since the CRaSH project itself is no longer actively supported.

WebFlux and WebFlux.fn Support

Spring Boot 2.0 provides a new starter for supporting the Reactive Spring web frameworks, for both annotation and functional based variants. spring-boot-starter-webflux brings WebFlux itself, plus Reactor Netty as a default web engine (spring-boot-starter-reactor-netty).

Reactive controllers can be tested using @WebFluxTest that provides a similar support than @WebMvcTest for Spring MVC. In particular a WebTestClient is auto-configured.

Maven Configuration

Following is a sample pom file to get started with Spring Boot 2.

pom.xml
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>

    <groupId>com.devglan</groupId>
    <artifactId>spring-boot-example</artifactId>
    <version>0.1.0-SNAPSHOT</version>
	<packaging>jar</packaging>
	
    <parent>
		<groupId>org.springframework.boot</groupId>
		<artifactId>spring-boot-starter-parent</artifactId>
		<version>2.0.0.M1</version>
		<relativePath/>
	</parent>

	</properties>

	<dependencies>
		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter</artifactId>
		</dependency>

		<dependency>
			<groupId>org.springframework.boot</groupId>
			<artifactId>spring-boot-starter-test</artifactId>
			<scope>test</scope>
		</dependency>
	</dependencies>

	<build>
		<plugins>
			<plugin>
				<groupId>org.springframework.boot</groupId>
				<artifactId>spring-boot-maven-plugin</artifactId>
			</plugin>
		</plugins>
	</build>

	<repositories>
		<repository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</repository>
		<repository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</repository>
	</repositories>

	<pluginRepositories>
		<pluginRepository>
			<id>spring-snapshots</id>
			<name>Spring Snapshots</name>
			<url>https://repo.spring.io/snapshot</url>
			<snapshots>
				<enabled>true</enabled>
			</snapshots>
		</pluginRepository>
		<pluginRepository>
			<id>spring-milestones</id>
			<name>Spring Milestones</name>
			<url>https://repo.spring.io/milestone</url>
			<snapshots>
				<enabled>false</enabled>
			</snapshots>
		</pluginRepository>
	</pluginRepositories>


</project>


Other Interesting Posts
Spring Data JPA Example
Spring Boot Hibernate 5 Example
Spring Boot Security Bcrypt Password Encoding
Spring Boot Multiple DB Example
Spring Boot JMS ActiveMQ Example
Spring Boot Actuator Tutorial
Spring 5 Features
Spring Boot Security Rest basic Authentication

Gradle Configuration

build.gradle
buildscript {
	ext {
		springBootVersion = '2.0.0.M1'
	}
	repositories {
		mavenCentral()
		maven { url "https://repo.spring.io/snapshot" }
		maven { url "https://repo.spring.io/milestone" }
	}
	dependencies {
		classpath("org.springframework.boot:spring-boot-gradle-plugin:${springBootVersion}")
	}
}

apply plugin: 'java'
apply plugin: 'eclipse'
apply plugin: 'org.springframework.boot'
apply plugin: 'io.spring.dependency-management'

version = '0.0.1-SNAPSHOT'
sourceCompatibility = 1.8

repositories {
	mavenCentral()
	maven { url "https://repo.spring.io/snapshot" }
	maven { url "https://repo.spring.io/milestone" }
}


dependencies {
	compile('org.springframework.boot:spring-boot-starter')
	testCompile('org.springframework.boot:spring-boot-starter-test')
}

Conclusion

I hope this article served you that you were looking for. If you have anything that you want to add or share then please share it below in the comment section.

Share

If You Appreciate This, You Can Consider:

We are thankful for your never ending support.

About The Author

author-image
A technology savvy professional with an exceptional capacity to analyze, solve problems and multi-task. Technical expertise in highly scalable distributed systems, self-healing systems, and service-oriented architecture. Technical Skills: Java/J2EE, Spring, Hibernate, Reactive Programming, Microservices, Hystrix, Rest APIs, Java 8, Kafka, Kibana, Elasticsearch, etc.

Further Reading on Spring Boot