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