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

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

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://www.net2asp.com/2d37cb747b.html