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

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

1. 问题出现原因

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

2. 解决方案

移除swagger2依赖

<dependency>
     <groupId>io.springfox</groupId>
     <artifactId>springfox-swagger2</artifactId>
     <version>2.9.2</version>
 </dependency>

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

添加新依赖

<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 = “”)

转载请说明出处内容投诉
CSS教程_站长资源网 » spring boot3.x集成swagger出现Type javax.servlet.http.HttpServletRequest not present

发表评论

欢迎 访客 发表评论

一个令你着迷的主题!

查看演示 官网购买