Springboot 1.X和Springboot 2.0之间的区别

时间:2018-03-10 02:57:18

标签: spring-boot

我们一直在为我们的应用程序使用Springboot 1.X. 现在正准备开始一些新的应用程序,并想知道我们是否应该使用SpringBoot2.0或坚持使用SpringBoot 1.X?

对这种或那种方式的任何想法? 另外,Spring Boot 1.X与Spring Boot 2.0有什么区别?

感谢。

3 个答案:

答案 0 :(得分:8)

您可以在此处找到差异和迁移指南: https://github.com/spring-projects/spring-boot/wiki/Spring-Boot-2.0-Migration-Guide

  • Java 8是基础版
  • 属性已更改
  • spring.jackson.serialization.write-dates-as-timestamps = true是默认值
  • Spring Security配置变得更容易
  • Spring Security Oauth2合并到Spring Security

依旧......

答案 1 :(得分:7)

SpringBoot 2. *更改:

1. Java 8 是最低版本

2. Tomcat 版本是最低版本 8.5

3. 休眠版本 5.2 是最低版本

4. 成绩版本 3.4 是最低版本

5。为 WebFlux 添加了SpringBoot Starters,并为 Cassandra MongoDB Redis 提供了响应式支持。

>

6. 自动配置

a。安全性(需要添加一个bean来公开执行器端点,例如健康状况)

示例代码 :(根据您的需要修改以下代码)

@Configuration
public class ApplicationSecurity extends WebSecurityConfigurerAdapter {

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

b。需要添加 spring-boot-starter-security 依赖项:

    <dependency>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-security</artifactId>
    </dependency>
  1. 执行器端点更改:

    2. *之前的版本http://localhost:8080/business-customer/profile / env 将给出 详细信息。

    从2。* 开始:http://localhost:8080/business-customer/profile / actuator / env 提供详细信息。

  2. application.properties 中的
  3. 端点属性(以启用所有端点)

    management.endpoints.web.exposure.include = * management.endpoints.web.exposure.exclude =记录器

  4. 默认情况下,
  5. 连接池

    2. *之前的版本:tomcat CP

    2. 之后: HikariCP (来自SpringBoot 2。)您无需添加HikariCP             依赖关系及其配置Bean创建及其属性             更改。)

  6. 迁移https://spring.io/blog/2018/03/12/upgrading-start-spring-io-to-spring-boot-2

答案 2 :(得分:0)

从组件扫描到自动创建表到连接的数据库,大多数事情都将以2倍的速度自动配置