Reputation: 297
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.
Upvotes: 25
Views: 29159
Reputation: 1202
You can find differences and migration guide here : https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide
Upvotes: 26
Reputation: 696
You can follow this: https://www.baeldung.com/new-spring-boot-2
Spring Boot 2.x is the first version to support Java 9.
In 2.x by default, everything is secured, including static resources and Actuator endpoints.
In Spring Boot 1.x only Spring-MVC was supported for actuator endpoints. In 2.x, however, it became independent and pluggable.
In 2.x when our application gets restarted by devtools a ‘delta' report will be printed out.
Tomcat minimum supported version is 8.5
Hibernate minimum supported version is 5.2
Gradle minimum supported version is 3.4
Upvotes: 1
Reputation: 19
most of the things are getting autoconfigured in 2x from component Scan to auto table creation to the db connected
Upvotes: 1
Reputation: 341
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
Upvotes: 23