好得很程序员自学网

<tfoot draggable='sEl'></tfoot>

springboot更新配置Swagger3的一些小技巧

1.引入依赖,版本3.0.0只引入一个即可

?

1

2

3

4

5

<dependency>

             <groupId>io.springfox</groupId>

             <artifactId>springfox-boot-starter</artifactId>

             <version> 3.0 . 0 </version>

         </dependency>

2. 配置类SwaggerConfig

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

41

package org.fh.config;

 

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.oas.annotations.EnableOpenApi;

import springfox.documentation.service.ApiInfo;

import springfox.documentation.spi.DocumentationType;

import springfox.documentation.spring.web.plugins.Docket;

 

/**

  * 说明:Swagger 接口API生成

  * 作者:FH Admin

  * from fhadmin.cn

  */

@Configuration

@EnableOpenApi

public class SwaggerConfig {

 

     @Bean

     public Docket createRestApi() {

         return new Docket(DocumentationType.OAS_30)

                 .apiInfo(apiInfo())

                 .select()

                 .apis(RequestHandlerSelectors.basePackage( "org.fh.controller" ))    // 为当前包路径

                 .paths(PathSelectors.any())

                 .build();

     }

 

     private ApiInfo apiInfo() {

         return new ApiInfoBuilder()

                 .title( "FH Admin Swagger3 RESTful API" )     // 页面标题

                 .version( "3.0" )                                // 版本号

                 .description( "fhadmin.org" )                    // 描述

                 .build();

     }

 

}

3.Swagger 拦截配置

?

1

2

3

4

5

6

7

8

9

10

11

12

13

14

15

16

17

18

19

20

21

22

23

24

25

26

27

28

29

30

31

32

33

34

35

36

37

38

39

40

package org.fh.config;

 

import org.springframework.context.annotation.Configuration;

import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;

import org.springframework.web.servlet.config.annotation.ViewControllerRegistry;

import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

 

/**

  * 说明:Swagger 拦截配置

  * 作者:FH Admin

  * from fhadmin.cn

  */

@Configuration

public class WebMvcConfig implements WebMvcConfigurer {

 

     @Override

     public void addResourceHandlers(ResourceHandlerRegistry registry) {

         registry.

                 addResourceHandler( "/swagger-ui/**" )

                 .addResourceLocations( "classpath:/META-INF/resources/webjars/springfox-swagger-ui/" )

                 .resourceChain( false );

     }

 

     @Override

     public void addViewControllers(ViewControllerRegistry registry) {

         registry.addViewController( "/swagger-ui/" )

                 .setViewName( "forward:/swagger-ui/index.html" );

     }

}

 

4 .访问 127.0 . 0.1 : 8081 /swagger-ui/index.html

 

5 .接口说明案例

 

处理类上加注解,比如

@Api ( "用户注册登录接口" )

 

在方法上加注解,比如

@ApiOperation (value = "登录" , notes= "校验登录是否成功" )

@ApiImplicitParam (name = "KEYDATA" , value = "用户名密码混淆码组合" , paramType = "query" , required = true , dataType = "String" )

工作流模块-------------------------------HdhCmsTestfhadmin.cn

1.模型管理:web在线流程设计器、导入导出xml、复制流程、部署流程

2.流程管理:导入导出流程资源文件、查看流程图、根据流程实例反射出流程模型、激活挂起

3.运行中流程:查看流程信息、当前任务节点、当前流程图、作废暂停流程、指派待办人、自由跳转

4.历史的流程:查看流程信息、流程用时、流程状态、查看任务发起人信息

5.待办任务:查看本人个人任务以及本角色下的任务、办理、驳回、作废、指派一下代理人

6.已办任务:查看自己办理过的任务以及流程信息、流程图、流程状态(作废 驳回 正常完成)

办理任务时候可以选择用户进行抄送,就是给被抄送人发送站内信通知当前审批意见以及备注信息

注:当办理完当前任务时,下一任务待办人会即时通讯收到新任务消息提醒,当作废和完结任务时,

任务发起人会收到站内信消息通知

到此这篇关于springboot Swagger3 更新配置的一些小技巧的文章就介绍到这了,更多相关springboot Swagger3 更新配置内容请搜索以前的文章或继续浏览下面的相关文章希望大家以后多多支持!

原文链接:https://HdhCmsTestcnblogs测试数据/teacher11/p/14953630.html

查看更多关于springboot更新配置Swagger3的一些小技巧的详细内容...

  阅读:16次