更改系统接口扫描方式

master
RuoYi 6 years ago committed by Limy
parent 39c187d6ec
commit 2728a72a96

@ -3,6 +3,7 @@ package com.ruoyi.web.core.config;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import com.ruoyi.common.config.Global; import com.ruoyi.common.config.Global;
import io.swagger.annotations.ApiOperation;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
@ -28,11 +29,14 @@ public class SwaggerConfig
public Docket createRestApi() public Docket createRestApi()
{ {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
// 详细定制 // 用来创建该API的基本信息展示在文档的页面中自定义展示的信息
.apiInfo(apiInfo()) .apiInfo(apiInfo())
// 设置哪些接口暴露给Swagger展示
.select() .select()
// 指定当前包路径 // 扫描所有有注解的api用这种方式更灵活
.apis(RequestHandlerSelectors.basePackage("com.ruoyi.web.controller.tool")) .apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
// 扫描指定包中的swagger注解
//.apis(RequestHandlerSelectors.basePackage("com.ruoyi.project.tool.swagger"))
// 扫描所有 .apis(RequestHandlerSelectors.any()) // 扫描所有 .apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()) .paths(PathSelectors.any())
.build(); .build();
@ -45,9 +49,13 @@ public class SwaggerConfig
{ {
// 用ApiInfoBuilder进行定制 // 用ApiInfoBuilder进行定制
return new ApiInfoBuilder() return new ApiInfoBuilder()
// 设置标题
.title("标题若依管理系统_接口文档") .title("标题若依管理系统_接口文档")
// 描述
.description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...") .description("描述:用于管理集团旗下公司的人员信息,具体包括XXX,XXX模块...")
// 作者信息
.contact(new Contact(Global.getName(), null, null)) .contact(new Contact(Global.getName(), null, null))
// 版本
.version("版本号:" + Global.getVersion()) .version("版本号:" + Global.getVersion())
.build(); .build();
} }

Loading…
Cancel
Save