Difference between Springboot 1.X and Springboot 2.0

most of the things are getting autoconfigured in 2x from component Scan to auto table creation to the db connected


SpringBoot 2.* Changes:

1.Java 8 is minimum version

2.Tomcat version 8.5 is minimum

3.Hibernate version 5.2 is minimum

4.Gradle version 3.4 is minimum

5.Added SpringBoot Starters for WebFlux and reactive support for Cassandra, MongoDB and Redis.

6.AutoConfiguration

a.Security (Need to add a bean to expose actuator endpoints like health etc)

Sample Code: (Modify below code based on your needs)

@Configuration
public class ApplicationSecurity extends WebSecurityConfigurerAdapter {

  @Override
  public void configure(WebSecurity web) throws Exception {
     web
        .ignoring()
            .antMatchers("/**");
     }
  }

b.Need to add spring-boot-starter-security dependency:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
  1. Actuator Endpoint change:

    Before 2.*: http://localhost:8080/business-customer/profile/env will give the details.

    From 2.*: http://localhost:8080/business-customer/profile/actuator/env will give the details.

  2. Endpoint properties in application.properties (to enable all endpoints)

    management.endpoints.web.exposure.include=* management.endpoints.web.exposure.exclude=loggers

  3. Connection Pool by default:

    Before 2.*: tomcat CP

    After 2.: HikariCP (from SpringBoot 2. You don't need to add HikariCP dependency and its config bean creation and its properties changes.)

  4. Migration: https://spring.io/blog/2018/03/12/upgrading-start-spring-io-to-spring-boot-2


You can find differences and migration guide here : https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide

  • Java 8 is base version
  • properties changed
  • spring.jackson.serialization.write-dates-as-timestamps=true is default value
  • Spring Security configuration become easier
  • Spring Security Oauth2 merges into Spring Security
  • Better dependency management

Tags:

Spring Boot