项目升级java17遇到的问题与解决方案

项目升级java17,对应框架也全部升级,SpringBoot也升级到3.x

迁移环境

java8 ---> java17
SpringBoot ---> 3.0.2
SrpingCloud ---> 2022.0.0.0

代码修改

在idea中使用全局替换功能,选择正则表达式模式,以下替换内容,按顺序执行并替换所有内容

  • import javax\.websocket 替换为 import jakarta.websocket
  • import javax\.servlet 替换为 import jakarta.servlet
  • import io\.swagger\.annotations\.Api\; 替换为 import io.swagger.v3.oas.annotations.tags.Tag;
  • import io\.swagger\.annotations\.ApiOperation\; 替换为 import io.swagger.v3.oas.annotations.Operation;
  • @Api\(value = "(.*?)", tags = \{"(.*?)"\}\) 替换为 @Tag(name = \"$1\", description = \"$2\")
  • \@ApiOperation\(value \= \"(.*?)\"\) 替换为 @Operation(summary = "$1")
  • \@ApiOperation\(\"(.*?)\"\) 替换为 @Operation(summary = "$1")
  • import io\.swagger\.annotations\.ApiModelProperty\; 替换为 对就是空字符串
  • import io\.swagger\.annotations\.ApiModel\; 替换为 import io.swagger.v3.oas.annotations.media.Schema;
  • \@ApiModelProperty\(value \= \"(.*?)\"\) 替换为 @Schema(description = "$1")
  • \@ApiMode\(\"(.*?)\"\) 替换为 @Schema(name = "$1")

问题与解决方案

No spring.config.import property has been defined

使用了bootstrap.yml需要引入以下依赖

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-bootstrap</artifactId>
</dependency>

无法解析符号 'Session'

<dependency>
    <groupId>jakarta.websocket</groupId>
    <artifactId>jakarta.websocket-client-api</artifactId>
    <version>2.1.0</version>
</dependency>

Correct the classpath of your application so that it contains compatible versions of the classes com.baomidou.mybatisplus.extension.plugins.inner.PaginationInnerInterceptor and net.sf.jsqlparser.schema.Column

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>2.0.0</version>
</dependency>

No Feign Client for loadBalancing defined. Did you forget to include spring-cloud-starter-loadbalancer?

<dependency>
    <groupId>org.springframework.cloud</groupId>
    <artifactId>spring-cloud-starter-loadbalancer</artifactId>
</dependency>

org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'com.github.pagehelper.autoconfigure.PageHelperAutoConfiguration': Bad return type

<dependency>
    <groupId>com.github.pagehelper</groupId>
    <artifactId>pagehelper-spring-boot-starter</artifactId>
    <version>2.0.0</version> <!--2.1.0版本有问题-->
</dependency>

淡淡的心,回味的情