首页 > 其他分享 >整合swagger2

整合swagger2

时间:2023-04-20 21:44:44浏览次数:36  
标签:Docket documentation swagger2 整合 new import springfox com

添加配置类

import com.google.common.base.Predicates;
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.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

@Configuration
@EnableSwagger2
public class Swagger2Config {
    @Bean
    public Docket webApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("webApi")
                .apiInfo(webApiInfo())
                .select()
                //只显示api路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/api/.*")))
                .build();
    }

    @Bean
    public Docket adminApiConfig(){
        return new Docket(DocumentationType.SWAGGER_2)
                .groupName("adminApi")
                .apiInfo(adminApiInfo())
                .select()
                //只显示admin路径下的页面
                .paths(Predicates.and(PathSelectors.regex("/admin/.*")))
                .build();
    }

    private ApiInfo webApiInfo(){
        return new ApiInfoBuilder()
                .title("网站-API文档")
                .description("本文档描述了网站微服务接口定义")
                .version("1.0")
                .contact(new Contact("atguigu", "http://atguigu.com", "[email protected]"))
                .build();
    }

    private ApiInfo adminApiInfo(){
        return new ApiInfoBuilder()
                .title("后台管理系统-API文档")
                .description("本文档描述了后台管理系统微服务接口定义")
                .version("1.0")
                .contact(new Contact("atguigu", "http://atguigu.com", "[email protected]"))
                .build();
    }
}

 

启动类上添加配置类的包扫描

@ComponentScan(basePackages = "com.xxx")

 

页面访问

http://localhost:8201/swagger-ui.html

 

标签:Docket,documentation,swagger2,整合,new,import,springfox,com
From: https://www.cnblogs.com/ixtao/p/17338454.html

相关文章

  • Nacos笔记(五):Nacos集群整合Nginx
    前言Nginx搭建,参考:Linux安装Nginx。1、Nginx配置添加nacos集群,调整端口与服务名,并设置代理,详情如下:   配置详情如下http{includemime.types;default_typeapplication/octet-stream;sendfileon;keepalive_timeout......
  • 使用cistrome BETA整合ChIPseq和RNAseq
     写在前面:在获得同一个样本多种测序数据后,一个自然的目标就是整合,general的问题就是:表观是如何影响转录的?基本的数据种类:TFbinding,ChIP-seq和Cut&RunHistoneprofile,ChIP-seq和Cut&RunOpenchromatin,ATAC-seqGeneexpression,RNA-seq具体的问题就是:表观转录调控是如......
  • Chatgpt 帮忙写的脚本_使用powershell 写一段代码,功能实现将指定目录下多个csv 文件整
    需求:使用powershell写一段代码,功能实现将指定目录下多个csv文件整合成一个csv文件以下是使用PowerShell实现将指定目录下多个CSV文件合并为一个的示例代码:powershell点击查看代码#设置源目录和目标文件路径$sourceDirectory="C:\path\to\csv\files"$targetFilePa......
  • SpringBoot中配置Swagger2
    首先在pom.xml添加springfox-swagger2和springfox-swagger-ui两个依赖,并且spring-boot-starter-parent的版本不能太高,可以设置为2.1.6.RELEASE<!--https://mvnrepository.com/artifact/io.springfox/springfox-swagger2--><dependency> <groupId>io.springfox</groupId>......
  • Springboot整合Flowable6.x导出bpmn20
    项目源码仓库BPMN2.0(BusinessProcessModelandNotation)是一套业务流程模型与符号建模标准,以XML为载体,以符号可视化业务,支持精准的执行语义来描述元素的操作。Flowable诞生于Activiti,是一个使用Java编写的轻量级业务流程引擎。Flowable流程引擎可用于部署BPMN2.0流程定义,可以......
  • 瓴羊quickbi工具的妙用:多场景多业务下的数据整合与分析
    瓴羊QuickBI近日内推出了30天免费试用的活动,对于想要引入大数据分析工具的企业来说可谓是千载难逢的机会。想要免费体验瓴羊bi工具,只需要搜索“瓴羊QuickBI”,进入瓴羊QuickBI官网,就能申请参加这个免费活动,体验瓴羊QuickBI的大数据处理能力了。在数字经济时代,人们常常用数据量、......
  • Failed to process import candidates for configuration class [springfox.documenta
     org.springframework.beans.factory.BeanDefinitionStoreException:Failedtoprocessimportcandidatesforconfigurationclass[springfox.documentation.swagger2.configuration.Swagger2DocumentationConfiguration];nestedexceptionisjava.lang.IllegalArgumen......
  • springboot整合swagger2
     1.正文1.1什么是swagger2Swagger是一个规范和完整的框架,用于生成、描述、调用和可视化RESTful风格的Web服务的接口文档 .接口:controller相应的路径方法Swagger2是一款前后端分离开发中非常实用的API管理工具,它可以帮助开发者根据约定规范自动生成API文档,并支持......
  • struts2整合convention插件
    <?xmlversion="1.0"encoding="UTF-8"?><!DOCTYPEstrutsPUBLIC"-//ApacheSoftwareFoundation//DTDStrutsConfiguration2.1//EN""http://struts.apache.org/dtds/struts-2.1.dtd"><struts><consta......
  • Java MyBatis-Plus(4)MybatisPlus整合Pagehelper实现分页
    序言 /***pageInfo对象中属性含义*privateintpageNum;//当前页码*privateintpageSize;//设置每页多少条数据*privateintsize;//当前页有多少条数据*privateintstartRow;//当前页码第一条数据的*privateintendRow;//......