SpringBoot 2.3 升级到 SpringBoot 2.7 爬坑-- Swagger 3
SpringBoot 2.3 升级到 SpringBoot 2.7 爬坑-- Swagger 报错 需要升级 到 3
详细见:https://www.cnblogs.com/vipsoft/p/18489922
SpringBoot 2.7 爬坑-- SpringDoc & Swagger (支持 SpringBoot 3.X)
Failed to start bean 'documentationPluginsBootstrapper'; nested exception is java.lang.NullPointerException
添加yml配置
# Docs API配置
springdoc:
swagger-ui:
# API文档, 默认路径:swagger-ui/index.html, 通过http://localhost:8080/docs/index.html访问
path: /docs/index.html
# 开启Swagger UI界面
enabled: true
# 根据HTTP方法对API路径进行排序
operations-sorter: method
api-docs:
# OpenAPI的路径描述,默认路径:/v3/api-docs, 通过http://localhost:8080/docs/api访问文档描述
# OpenAPI描述定义默认为JSON格式, 通过http://localhost:8080/docs/api.yaml获取yaml格式
path: /docs/api
# 开启api-docs
enabled: true
# 配置需要生成接口文档的扫描包路径
packages-to-scan: com.vipsoft.admin.controller
# 配置需要生成接口文档的接口路径
# paths-to-match: /test/**,/user/**
修改 pom 引用
删除旧的 引用 swagger 2
<!-- swagger 2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- swagger 2 -->
<!-- 改为 -->
<!-- swagger 3 -->
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-ui</artifactId>
<version>${springdoc.version}</version>
</dependency>
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-webmvc-core</artifactId>-->
<!-- <version>${springdoc.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>io.swagger.core.v3</groupId>-->
<!-- <artifactId>swagger-annotations</artifactId>-->
<!-- <version>${swagger.core.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-webflux-ui</artifactId>-->
<!-- <version>${springdoc.version}</version>-->
<!-- </dependency>-->
<!-- <dependency>-->
<!-- <groupId>org.springdoc</groupId>-->
<!-- <artifactId>springdoc-openapi-security</artifactId>-->
<!-- <version>${springdoc.version}</version>-->
<!-- </dependency>-->
<!-- swagger 3 -->
Config 配置
SwaggerConfig 删除旧的配置
@Configuration
@EnableSwagger2
@Profile({"dev","test","local"})
public class SwaggerConfig {
详细见:https://www.cnblogs.com/vipsoft/p/18489922
}
改为
@Configuration
public class OpenApiConfig {
详细见:https://www.cnblogs.com/vipsoft/p/18489922
}
本文来自博客园,作者:VipSoft 转载请注明原文链接:https://www.cnblogs.com/vipsoft/p/18486612
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】凌霞软件回馈社区,博客园 & 1Panel & Halo 联合会员上线
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】博客园社区专享云产品让利特惠,阿里云新客6.5折上折
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 一个费力不讨好的项目,让我损失了近一半的绩效!
· 清华大学推出第四讲使用 DeepSeek + DeepResearch 让科研像聊天一样简单!
· 实操Deepseek接入个人知识库
· CSnakes vs Python.NET:高效嵌入与灵活互通的跨语言方案对比
· Plotly.NET 一个为 .NET 打造的强大开源交互式图表库
2023-10-19 HanLP — 双数组字典树 (Double-array Trie) 实现原理 -- 代码 + 图文,看不懂你来打我
2022-10-19 Kubernetes(K8S) Deployment 升级和回滚
2022-10-19 Kubernetes(K8S) 拉取镜像 ImagePullBackOff pull access denied
2022-10-19 Kubernetes(K8S) Deployment 拉取阿里云镜像部署
2012-10-19 利用反射代替switch
2012-10-19 Excel合并行的数据