news 2026/4/18 3:15:54

SpringBoot 3.4.x踩坑记录及解决方案(持续更新)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
SpringBoot 3.4.x踩坑记录及解决方案(持续更新)
废话
最近使用JDK17+Spring Boot3.4.0 做新项目遇到的一些坑,记录并且给出一些实际的解决方案
一、集成Mybatis Plus 3.5.9的问题

第一:不能只引入mybatis-plus-spring-boot3-starter依赖了,需要配合mybatis-plus-jsqlparser

<dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-spring-boot3-starter</artifactId> </dependency> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-jsqlparser</artifactId> </dependency>

第二:版本统一管理

<dependencyManagement> <dependencies> <dependency> <groupId>com.baomidou</groupId> <artifactId>mybatis-plus-bom</artifactId> <version>3.5.9</version> <type>pom</type> <scope>import</scope> </dependency> </dependencies> </dependencyManagement>

详情请见:https://baomidou.com/getting-started/install/

二、集成Knife4j-OpenApi3

这个改动真的有点大,切费老鼻子劲了,不建议旧项目直接迁移,不然得改到S3赛季开战!

<dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> <version>4.4.0</version> </dependency>

1、实体类写法变动
没有@ApiModel 和@ApiModelProperty写法,全局使用@Schema

@Schema(name = "OaDeptDTO对象", description = "部门表") public class OaDeptDTO implements Serializable { @Serial private static final long serialVersionUID = 1L; @Schema(description = "主键") private Long id; @Schema(description = "父部门id",defaultValue = "0") private Long parentId; @Schema(description = "部门名称") private String deptName; @Schema(description = "部门编码") private String deptCode; @Schema(description = "状态(0正常 1停用)") private Integer status; }

2 接口类写法

没有@Api和@ApiOperation写法

旧版本

新版本

@Api

@Tag

@ApiOperationi

@Operation

@Tag(name = "部门表") @RestController @RequiredArgsConstructor @RequestMapping("/oa/dept") public class OaDeptController { private final OaDeptAppService oaDeptAppService; @Operation(summary = "新增部门") @PostMapping("/add") public Result<Boolean> add(@RequestBody OaDeptDTO oaDept) { return Result.ok(oaDeptAppService.add(oaDept)); } }

注意注意请注意(呜呜呜~~~~)

Knife4j-OpenApi3存在一个大问题,如果你的项目中存在全局异常拦截类,@RestControllerAdvice/@ControllerAdvice,访问接口文档会报错,这是版本得bug,所以你无需自卑也不要过度伤心,叉掉你浏览器上密密麻麻的标签页吧。

详情见issue:https://github.com/xiaoymin/knife4j/issues/865

解决方案:升级springdoc-openapi-starter-webmvc-ui 2.7.0

<dependency> <groupId>com.github.xiaoymin</groupId> <artifactId>knife4j-openapi3-jakarta-spring-boot-starter</artifactId> <version>${knife4j.version}</version> <exclusions> <exclusion> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> </exclusion> </exclusions> </dependency> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.7.0</version> </dependency>
三、接口写法变动

之前的写法:(这样一直没毛病啊,但是3.4.0不行!!!!)

@Operation(summary = "查询数据明细") @GetMapping("/{id}") public Result<OaRoleVO> detail(@PathVariable Long id) { return Result.ok(oaRoleAppService.detail(id)); }

报错信息:

Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception [Request processing failed: java.lang.IllegalArgumentException: Name for argument of type [java.lang.Long] not specified, and parameter name information not available via reflection. Ensure that the compiler uses the '-parameters' flag.] with root cause

解决方案:

@Operation(summary = "查询数据明细") @GetMapping("/{id}") public Result<OaRoleVO> detail(@PathVariable("id") Long id) { return Result.ok(oaRoleAppService.detail(id)); }
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/4/17 15:30:35

PDF-Extract-Kit布局检测实战:精准识别文档结构的完整教程

PDF-Extract-Kit布局检测实战&#xff1a;精准识别文档结构的完整教程 1. 引言 1.1 文档智能提取的技术背景 在数字化转型加速的今天&#xff0c;PDF作为最广泛使用的文档格式之一&#xff0c;承载着大量学术论文、技术报告、合同文件等关键信息。然而&#xff0c;传统PDF解…

作者头像 李华
网站建设 2026/4/18 10:58:22

PDF-Extract-Kit性能优化:异步处理与队列管理

PDF-Extract-Kit性能优化&#xff1a;异步处理与队列管理 1. 背景与挑战 PDF-Extract-Kit 是一个由开发者“科哥”二次开发构建的 PDF 智能提取工具箱&#xff0c;集成了布局检测、公式识别、OCR 文字识别、表格解析等核心功能。其基于 YOLO 模型、PaddleOCR 和深度学习技术&…

作者头像 李华
网站建设 2026/4/18 8:46:17

混元翻译模型1.5性能测试:量化前后对比分析

混元翻译模型1.5性能测试&#xff1a;量化前后对比分析 1. 引言 随着多语言交流需求的不断增长&#xff0c;高质量、低延迟的机器翻译系统成为智能应用的核心组件。腾讯近期开源了混元翻译模型1.5版本&#xff08;HY-MT1.5&#xff09;&#xff0c;包含两个主力模型&#xff1…

作者头像 李华
网站建设 2026/4/17 22:37:41

Proteus使用教程零基础指南:快速上手电子设计仿真

从零开始玩转Proteus&#xff1a;电子设计仿真实战入门指南 你有没有过这样的经历&#xff1f; 焊了一块电路板&#xff0c;通电后芯片冒烟&#xff1b;写好的单片机程序下载进去&#xff0c;外设毫无反应&#xff0c;却不知道是代码错了还是接线错了&#xff1b;想做个课程设…

作者头像 李华
网站建设 2026/4/18 10:38:04

HY-MT1.5-7B混合语言检测:算法原理与调优

HY-MT1.5-7B混合语言检测&#xff1a;算法原理与调优 1. 技术背景与问题提出 随着全球化进程加速&#xff0c;跨语言交流需求激增&#xff0c;传统翻译模型在面对混合语言输入&#xff08;如中英夹杂、方言与标准语混用&#xff09;时表现不佳。尽管大模型在翻译质量上取得显…

作者头像 李华
网站建设 2026/4/17 3:09:29

Keil和Proteus联调方法图解说明:时序同步技巧

Keil与Proteus联调实战指南&#xff1a;软硬协同仿真中的时序同步艺术在嵌入式开发的世界里&#xff0c;有一个经典的“鸡生蛋”问题&#xff1a;没有硬件&#xff0c;怎么调试代码&#xff1f;没有代码&#xff0c;怎么验证电路&#xff1f;传统做法是先画板、打样、焊接&…

作者头像 李华