spring boot3.x集成swagger出现Type javax.servlet.http.HttpServletRequest not present

1. 问题出现原因

spring boot3.x版本依赖于jakarta依赖包,但是swagger依赖底层应用的javax依赖包,所以只要已启动就会报错。

2. 解决方案

移除swagger2依赖

xml 复制代码
<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger2</artifactId>
     <version>2.9.2</version>
 </dependency>

 <dependency>
     <groupId>com.github.xiaoymin</groupId>
     <artifactId>swagger-bootstrap-ui</artifactId>
     <version>1.9.0</version>
     <scope>provided</scope>
 </dependency>

添加新依赖

xml 复制代码
<dependency>
    <groupId>org.springdoc</groupId>
    <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
    <version>2.1.0</version>
</dependency>

标签替换

@Api(tags = "") → @Tag(name = "")

@ApiModel(value="", description="") → @Schema(name="", description="")

@ApiModelProperty(value = "", required = true) → @Schema(name= "", description = "", required = true)

@ApiOperation(value = "", notes = "") → @Operation(summary = "", description = "")

@ApiParam → @Parameter

@ApiResponse(code = 404, message = "") → @ApiResponse(responseCode = "404", description = "")

相关推荐
YY&DS1 天前
Qt 快速搭建局域网 HTTP 下载服务(兼容 IE/Chrome/Edge/Firefox)
chrome·qt·http
踏浪无痕1 天前
手写Spring事务框架:200行代码揭开@Transactional的神秘面纱( 附完整源代码)
spring boot·spring·spring cloud
R***62311 天前
Spring Boot 整合 log4j2 日志配置教程
spring boot·单元测试·log4j
0***h9421 天前
使用 java -jar 命令启动 Spring Boot 应用时,指定特定的配置文件的几种实现方式
java·spring boot·jar
刘一说1 天前
Nacos 与 Spring Cloud Alibaba 集成详解:依赖、配置、实战与避坑指南
spring boot·spring cloud·微服务·架构
一 乐1 天前
购物|明星周边商城|基于springboot的明星周边商城系统设计与实现(源码+数据库+文档)
java·数据库·spring boot·后端·spring
q***51891 天前
Spring Boot中Tomcat配置
spring boot·tomcat·firefox
V***u4531 天前
【学术会议论文投稿】Spring Boot实战:零基础打造你的Web应用新纪元
前端·spring boot·后端
A***F1571 天前
SpringBoot(整合MyBatis + MyBatis-Plus + MyBatisX插件使用)
spring boot·tomcat·mybatis
l***46681 天前
SSM与Springboot是什么关系? -----区别与联系
java·spring boot·后端