Springdoc-openapi。 ClassNotFoundException:org.springframework.data.rest.webmvc.support.DefaultedPageable

Springdoc-openapi. ClassNotFoundException: org.springframework.data.rest.webmvc.support.DefaultedPageable

迁移 Spring 引导到版本 3.1 和 springdoc-openapi 库到 1.4.1 之后:

我遇到了问题ClassNotFoundException: org.springframework.data.rest.webmvc.support.DefaultedPageable

现在还在 Swagger UI 上生成了 @Entity 的页面控制器和模式,但是之前只有来自 @RestController 的端点、请求和响应 DTO。有什么方法可以禁用它吗?

根据您的描述,您不需要加载 springdoc-openapi-data-rest。 (你会加载与spring-data-rest相关的不必要的bean)

如果你只是需要启用Pageable的支持,你可以添加下面一行:

SpringDocUtils.getConfig().replaceWithClass(org.springframework.data.domain.Pageable.class, Pageable.class);

这里有解释:https://springdoc.org/ [Spring 数据休息支持]

或者,如果你想依赖spring-boot-starter-data-rest,那么添加依赖。