spring-mvc - 如何在普通春季项目中将 swagger2 升级到 swagger3
问题描述
在我们的spring-webmvc项目中我们使用下面的代码来配置swagger2,现在我们想升级到swagger3,所以我们在pom文件中添加了springdoc-openapi-ui,我们需要在我们的swagger-configuration文件中进行哪些更改
@Configuration
@EnableSwagger2
public class SwaggerConfiguration {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.hjk.controller"))
.paths(PathSelectors.any())
.build()
.apiInfo(getApiInfo());
}
private ApiInfo getApiInfo() {
return new ApiInfo(title, description, version, termsOfServiceUrl, contact, license, licenseUrl);
}
}
解决方案
您必须像这样删除@EnableSwagger2
并更改您的Docket api()
。
@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI().info(new Info().title("SpringShop API"));}
有关更多详细信息,请参阅此文档https://springdoc.org/#migrating-from-springfox。
推荐阅读
- inno-setup - 用 Inno Setup 的 setup 子文件夹中的文件覆盖已安装的文件
- c++ - Visual Studio 2019 不强调 C++ 项目中的错误
- javascript - 搜索功能 .match() 区分大小写
- javascript - 如何使用 for 循环对用户插入的数字求和?
- python - 炸弹包括python中的有序对
- google-chrome-extension - Linux 安装上的 Chrome 扩展程序“包无效”错误
- python - poliastro epoch:如何指定非默认值?
- node.js - 为什么我的标题没有插入到我的数据库中?
- sql - 合计员工/plsql的总就业时间/年
- java - 为什么我必须为位掩码声明一个长变量?