Swagger3.0 整合spring boot2.7x避免swagger2.0與boot2.7沖突問(wèn)題
注釋掉2.0引入的倆包
直接引入3.0
<dependency> <groupId>io.springfox</groupId> <artifactId>springfox-boot-starter</artifactId> <version>3.0.0</version> </dependency>
swagger配置文件粘貼即用哦
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 @Configuration public class SwaggerConfig { @Bean public Docket createRestApi() { return new Docket(DocumentationType.SWAGGER_2) .apiInfo(apiInfo()) .select() //TODO 改為你項(xiàng)目使用的controller包目錄 .apis(RequestHandlerSelectors.basePackage("com.example.controller")) .paths(PathSelectors.any()) .build(); } //構(gòu)建api的詳細(xì)信息方法 private ApiInfo apiInfo() { return new ApiInfoBuilder() //頁(yè)面標(biāo)題 .title("xx接口文檔") //版本號(hào) .version("1.0") //描述 .description("swagger3.0的為基礎(chǔ)的文檔喲") .build(); } }
最后配置文件改變mvc匹配規(guī)則即可
spring: mvc: pathmatch: matching-strategy: ant_path_matcher
最后
swagger2.0訪問(wèn)地址是:
http://localhost:8080/swagger-ui.html
swagger3.0地址是:
http://localhost:8080/swagger-ui/index.html
到此這篇關(guān)于Swagger3.0 與spring boot2.7x 整合避免swagger2.0與boot2.7沖突的文章就介紹到這了,更多相關(guān)Swagger3.0 整合spring boot2.7x 內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
java?CompletableFuture異步任務(wù)編排示例詳解
這篇文章主要為大家介紹了java?CompletableFuture異步任務(wù)編排示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11Spring Boot優(yōu)雅地處理404異常問(wèn)題
這篇文章主要介紹了Spring Boot優(yōu)雅地處理404異常問(wèn)題,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-11-11簡(jiǎn)單了解Spring beanfactory循環(huán)依賴(lài)命名重復(fù)屬性
這篇文章主要介紹了簡(jiǎn)單了解Spring beanfactory循環(huán)依賴(lài)命名重復(fù)2大屬性,文中通過(guò)示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友可以參考下2020-06-06Java語(yǔ)法基礎(chǔ)之for語(yǔ)句練習(xí)
以下是對(duì)Java語(yǔ)法基礎(chǔ)中的for語(yǔ)句進(jìn)行了詳細(xì)介紹,需要的朋友可以過(guò)來(lái)參考下2013-07-07java如何更改數(shù)據(jù)庫(kù)中的數(shù)據(jù)
這篇文章主要介紹了java如何更改數(shù)據(jù)庫(kù)中的數(shù)據(jù),修改數(shù)據(jù)庫(kù)是數(shù)據(jù)庫(kù)操作必不可少的一部分,使用Statement接口中的excuteUpdate()方法可以修改數(shù)據(jù)表中的數(shù)據(jù),感興趣的朋友跟隨小編一起看看吧2021-11-11