spring boot3.x集成swagger出现Type javax.servlet.http.HttpServletRequest not present
作者:mmseoamin日期:2023-12-18

1. 问题出现原因

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

2. 解决方案

移除swagger2依赖


     io.springfox
     springfox-swagger2
     2.9.2
 
 
     com.github.xiaoymin
     swagger-bootstrap-ui
     1.9.0
     provided
 

添加新依赖


    org.springdoc
    springdoc-openapi-starter-webmvc-ui
    2.1.0

标签替换

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