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

1. 问题出现原因

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

2. 解决方案

移除swagger2依赖

<dependency>
     <groupId>io.springfoxgroupId>
     <artifactId>springfox-swagger2artifactId>
     <version>2.9.2version>
 dependency>

 <dependency>
     <groupId>com.github.xiaoymingroupId>
     <artifactId>swagger-bootstrap-uiartifactId>
     <version>1.9.0version>
     <scope>providedscope>
 dependency>

添加新依赖

<dependency>
    <groupId>org.springdocgroupId>
    <artifactId>springdoc-openapi-starter-webmvc-uiartifactId>
    <version>2.1.0version>
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 = “”)

你可能感兴趣的:(JAVA学习,spring,boot,servlet,http)