Swagger3.0 整合spring boot2.7x避免swagger2.0與boot2.7沖突問題
注釋掉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 改為你項目使用的controller包目錄 .apis(RequestHandlerSelectors.basePackage("com.example.controller")) .paths(PathSelectors.any()) .build(); } //構(gòu)建api的詳細(xì)信息方法 private ApiInfo apiInfo() { return new ApiInfoBuilder() //頁面標(biāo)題 .title("xx接口文檔") //版本號 .version("1.0") //描述 .description("swagger3.0的為基礎(chǔ)的文檔喲") .build(); } }
最后配置文件改變mvc匹配規(guī)則即可
spring: mvc: pathmatch: matching-strategy: ant_path_matcher
最后
swagger2.0訪問地址是:
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)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
java?CompletableFuture異步任務(wù)編排示例詳解
這篇文章主要為大家介紹了java?CompletableFuture異步任務(wù)編排示例詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-11-11簡單了解Spring beanfactory循環(huán)依賴命名重復(fù)屬性
這篇文章主要介紹了簡單了解Spring beanfactory循環(huán)依賴命名重復(fù)2大屬性,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友可以參考下2020-06-06java如何更改數(shù)據(jù)庫中的數(shù)據(jù)
這篇文章主要介紹了java如何更改數(shù)據(jù)庫中的數(shù)據(jù),修改數(shù)據(jù)庫是數(shù)據(jù)庫操作必不可少的一部分,使用Statement接口中的excuteUpdate()方法可以修改數(shù)據(jù)表中的數(shù)據(jù),感興趣的朋友跟隨小編一起看看吧2021-11-11