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.
The current stable version, as of July 2022, is Spring 5.3. 22.
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.
You can find differences and migration guide here : https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide
and so on..
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>
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.
Endpoint properties in application.properties (to enable all endpoints)
management.endpoints.web.exposure.include=* management.endpoints.web.exposure.exclude=loggers
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.)
Migration: https://spring.io/blog/2018/03/12/upgrading-start-spring-io-to-spring-boot-2
most of the things are getting autoconfigured in 2x from component Scan to auto table creation to the db connected
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With