Spring Boot 3.x 整合Swagger的示例教程
解決Springfox 依賴注入失敗問題:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'apiDocumentationScanner' defined in URL ···
最佳方案是放棄 Springfox 2.x,改用 SpringDoc OpenAPI,因?yàn)椋?/p>
Springfox 2.x 已停止維護(hù)
Springfox 3.x 對 Spring Boot 支持有限
SpringDoc 是當(dāng)前最活躍的 Spring API 文檔項(xiàng)目
第一步:添加依賴:
<dependency>
<groupId>org.springdoc</groupId>
<artifactId>springdoc-openapi-starter-webmvc-ui</artifactId>
<version>2.5.0</version>
</dependency>第二步:添加配置:
@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info()
.title("Spring Boot 中使用 Swagger UI 構(gòu)建 RESTful API")
.contact(new Contact())
.description("Sun提供的 RESTful API")
.version("v1.0.0")
.license(new License().name("Apache 2.0")
.url("http://springdoc.org")))
.externalDocs(new ExternalDocumentation()
.description("外部文檔")
.url("https://springshop.wiki.github.org/docs"));
}
}application.properties配置:
springdoc.api-docs.path=/v3/api-docs springdoc.api-docs.enabled=true springdoc.swagger-ui.path=/swagger-ui.html springdoc.swagger-ui.enabled=true
第三步:訪問:
http://localhost:8080/swagger-ui.html
到此這篇關(guān)于Spring Boot 3.x 整合Swagger教程的文章就介紹到這了,更多相關(guān)Spring Boot 3.x 整合Swagger內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- SpringBoot3.1.2 引入Swagger報(bào)錯(cuò)Type javax.servlet.http.HttpServletRequest not present解決辦法
- Springboot整合Swagger2和Swagger3全過程
- springboot整合swagger3報(bào)Unable to infer base url錯(cuò)誤問題
- SpringBoot整合Swagger3生成接口文檔的示例代碼
- Springboot整合Swagger2后訪問swagger-ui.html 404報(bào)錯(cuò)問題解決方案
- springboot整合swagger3和knife4j的詳細(xì)過程
- Springboot整合Swagger3全注解配置(springdoc-openapi-ui)
- SpringBoot整合Swagger3生成接口文檔過程解析
相關(guān)文章
Maven配置項(xiàng)目依賴使用本地倉庫的方法匯總(小結(jié))
這篇文章主要介紹了Maven配置項(xiàng)目依賴使用本地倉庫的方法匯總(小結(jié)),文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-07-07
jsp+dao+bean+servlet(MVC模式)實(shí)現(xiàn)簡單用戶登錄和注冊頁面
這篇文章主要介紹了jsp+dao+bean+servlet(MVC模式)實(shí)現(xiàn)簡單用戶登錄和注冊頁面,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2020-12-12
java.net.MalformedURLException異常的解決方法
下面小編就為大家?guī)硪黄猨ava.net.MalformedURLException異常的解決方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-05-05
idea中使用SonarLint進(jìn)行代碼規(guī)范檢測及使用方法
這篇文章主要介紹了idea中使用SonarLint進(jìn)行代碼規(guī)范檢測,本文通過圖文并茂的形式給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2021-08-08
Springboot整合MybatisPlus的實(shí)現(xiàn)過程解析
這篇文章主要介紹了Springboot整合MybatisPlus的實(shí)現(xiàn)過程解析,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2019-10-10

