From 3ae519f7b66ae217a9500b0a9c2cef8212da8e27 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E4=BA=91=E4=B8=B6=E8=A8=80?= Date: Wed, 8 Jun 2022 21:57:01 +0800 Subject: [PATCH] =?UTF-8?q?=E7=BE=8E=E5=8C=96API=E6=96=87=E6=A1=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 2 +- pom.xml | 11 ++------ .../jieyue/common/config/Swagger2Config.java | 28 +++++++++---------- 3 files changed, 18 insertions(+), 23 deletions(-) diff --git a/README.md b/README.md index 72f3591..0c2c430 100644 --- a/README.md +++ b/README.md @@ -20,7 +20,7 @@ **后台模块:**[http://119.91.222.184/admin/login](http://119.91.222.184/admin/login)(账号-密码:guest@qq.com-123456) -**API 文档:** [http://119.91.222.184/swagger-ui.html](http://119.91.222.184/swagger-ui.html) +**API 文档:** [http://119.91.222.184/doc.html](http://119.91.222.184/doc.html)
diff --git a/pom.xml b/pom.xml index eb6aed5..26ec1b5 100644 --- a/pom.xml +++ b/pom.xml @@ -160,14 +160,9 @@ - io.springfox - springfox-swagger2 - 2.5.0 - - - io.springfox - springfox-swagger-ui - 2.5.0 + com.github.xiaoymin + knife4j-spring-boot-starter + 3.0.3 diff --git a/src/main/java/com/example/jieyue/common/config/Swagger2Config.java b/src/main/java/com/example/jieyue/common/config/Swagger2Config.java index 602f9fb..3ebf004 100644 --- a/src/main/java/com/example/jieyue/common/config/Swagger2Config.java +++ b/src/main/java/com/example/jieyue/common/config/Swagger2Config.java @@ -5,7 +5,6 @@ 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.service.Contact; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; @@ -14,21 +13,22 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 @Configuration public class Swagger2Config { - @Bean - public Docket mapRestApi() { - return new Docket(DocumentationType.SWAGGER_2).groupName("捷阅网API文档") - .apiInfo(apiInfo()).select() + @Bean(value = "defaultApi2") + public Docket defaultApi2() { + String groupName="2.0.5"; + Docket docket=new Docket(DocumentationType.OAS_30) + .apiInfo(new ApiInfoBuilder() + .title("捷阅网 API 文档") + .contact(new Contact("Bosen","https://bosen-once.gitee.io","13416263336@163.com")) + .version("2.0.5") + .build()) + //分组名称 + .groupName(groupName) + .select() + //这里指定Controller扫描包路径 .apis(RequestHandlerSelectors.basePackage("com.example.jieyue")) .paths(PathSelectors.any()) .build(); - } - - private ApiInfo apiInfo() { - return new ApiInfoBuilder() - .title("捷阅网API文档") - .description(" ") - .contact(new Contact("Bosen",null ,"13416263336.com")) - .version("2.0.5") - .build(); + return docket; } }