Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Difference between Springboot 1.X and Springboot 2.0

Tags:

spring-boot

We have been using Springboot 1.X for our applications. Now were are getting ready to start on a few new applications and was wondering if we should go with SpringBoot2.0 or stick with SpringBoot 1.X?

Any thoughts on one version or the other?

Also, what are the differences between Spring Boot 1.X vs Spring Boot 2.0?

Thanks.

like image 498
mysap Avatar asked Mar 10 '18 02:03

mysap


People also ask

Which version of Spring does spring boot use?

The current stable version, as of July 2022, is Spring 5.3. 22.

What is springboot2?

Spring Boot 2 brings a set of new starters for different reactive modules. Some examples are WebFlux, and the reactive counterparts for MongoDB, Cassandra or Redis. There are also test utilities for WebFlux. In particular, we can take advantage of @WebFluxTest.


3 Answers

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

and so on..

like image 163
Min Hyoung Hong Avatar answered Oct 26 '22 09:10

Min Hyoung Hong


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

like image 41
Putti Avatar answered Oct 26 '22 09:10

Putti


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

like image 38
Upendra Joshi Avatar answered Oct 26 '22 07:10

Upendra Joshi