天天看点

SpringBoot项目升级记

在原有项目中新增一个模块,打算升级基础框架

java:8->11

javax

在maven里加入以下依赖

<dependency>
            <groupId>javax.xml.bind</groupId>
            <artifactId>jaxb-api</artifactId>
            <version>2.3.0</version>
        </dependency>
           

springboot:1.5->2

Liquibase

在bootstrap.yml里位置改了,放到spring节点下面

spring:
  liquibase:
    enabled: true
    change-log: classpath:/db/changelog/db.changelog-master.xml
           

Feign

feign框架换成了OpenFeign

<dependency>
            <groupId>org.springframework.cloud</groupId>
            <artifactId>spring-cloud-starter-openfeign</artifactId>
            <version>2.2.0.RELEASE</version>
        </dependency>
           

Webflux

SpringBoot提供了webflux替代SpringMVC,基于Netty的Nio模型,再处理导出这样流数据的情况时效果比较好

<dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-webflux</artifactId>
        </dependency>
           

作为配套,PostgreSQL和Redis也换成reactor模式,但需要注意的是Spring Session仍然依赖的是传统模式

<dependency>
            <groupId>io.r2dbc</groupId>
            <artifactId>r2dbc-postgresql</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-r2dbc</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-redis-reactive</artifactId>
        </dependency>