Type javax.servlet.http.HttpServletRequest not present
运行环境 Swagger 3.0.0、springboot 3.0.0
产生原因: Swagger 3.0.0不支持spring3.0.0
两个解决方案:
1.降低springboot版本为2.x
2.放弃Swagger,使用 springdoc-openapi-starter-webmvc-ui
第二种解决方案:
<dependency><groupId>org.springdoc</groupId><artifactId>springdoc-openapi-starter-webmvc-ui</artifactId><version>2.0.0-M3</version> </dependency>
/*** 接口文档配置** @author Canva*/ @Configuration public class SpringDocConfig {@Beanpublic OpenAPI apiInfo() {return new OpenAPI().info(new Info().title("后端接口文档").version("1.0.0"));}@Beanpublic GroupedOpenApi httpApi() {return GroupedOpenApi.builder().group("http").pathsToMatch("/**").build();}}
注解变化 @Api ==>@Tag(name="",description="")
@ApiOperation==》@ApiResponse(description = "XXXX", content = @Content(mediaType = "application/json"))
@ApiModelProperty==》@Schema