关于swagger配置

swagger有多种样式,有些比较难用,如下界面比较友好

1.推荐对应的jar包如下

<!--swagger相关-->
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.7.0</version>
</dependency>
<dependency>
    <groupId>io.springfox</groupId>
    <artifactId>springfox-swagger-ui</artifactId>
    <version>2.7.0</version>
</dependency>
<!--swagger样式1 蓝色 默认支持数组参数格式友好显示-->
<dependency>
    <groupId>com.github.xiaoymin</groupId>
    <artifactId>swagger-bootstrap-ui</artifactId>
    <version>1.9.4</version>
</dependency>
<!--swagger样式2 黑色  默认不支持数组参数格式友好显示-->
<!--<dependency>
 <groupId>com.github.xiaoymin</groupId>
   <artifactId>knife4j-spring-boot-starter</artifactId>
   <version>2.0.6</version>
</dependency>-->

 2.建立配置文件SwaggerConfig

package com.func.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class SwaggerConfig {
    @Bean
    public Docket api() {
        return new Docket(DocumentationType.SWAGGER_2)
                .select()
                .apis(RequestHandlerSelectors.any())
                .paths(PathSelectors.any())
                .build();
    }
}

3.启动微服务,http://localhost:8080/ruyi/doc.html 

对应

server:
  port: 8080
  servlet:
    context-path: /ruyi

 

相关推荐

  1. Swagger使用配置笔记

    2024-04-07 03:36:02       40 阅读
  2. <span style='color:red;'>Swagger</span>

    Swagger

    2024-04-07 03:36:02      37 阅读
  3. SpringBoot配置Swagger开启页面访问限制

    2024-04-07 03:36:02       29 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-04-07 03:36:02       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-04-07 03:36:02       101 阅读
  3. 在Django里面运行非项目文件

    2024-04-07 03:36:02       82 阅读
  4. Python语言-面向对象

    2024-04-07 03:36:02       91 阅读

热门阅读

  1. 内建函数对象

    2024-04-07 03:36:02       105 阅读
  2. 图像识别与增强现实(AR)的结合

    2024-04-07 03:36:02       39 阅读
  3. docker部署nginx访问宿主机服务,并使用缓存

    2024-04-07 03:36:02       129 阅读
  4. Leetcode 537. 复数乘法

    2024-04-07 03:36:02       127 阅读
  5. Zookeeper 怎么实现分布式锁

    2024-04-07 03:36:02       47 阅读
  6. WebKit简单介绍

    2024-04-07 03:36:02       44 阅读
  7. vector容器

    2024-04-07 03:36:02       39 阅读
  8. 阿里云对象存储OSS的使用笔记

    2024-04-07 03:36:02       38 阅读
  9. centos7 安装 mysql5.7

    2024-04-07 03:36:02       45 阅读
  10. 网络工程师练习题(9)

    2024-04-07 03:36:02       43 阅读
  11. v-on内联语句

    2024-04-07 03:36:02       43 阅读
  12. 如何用python开发“跳一跳”游戏【附源码】

    2024-04-07 03:36:02       43 阅读
  13. 算法| ss 逻辑问题

    2024-04-07 03:36:02       41 阅读