在pom.xml文件中添加Maven依赖

<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>

新建一个config包,并在其下面添加Swagger配置类SwaggerConfig.java。

@Configurable
@EnableSwagger2
public class SwaggerConfig { @Bean
public Docket CreateRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select().
apis(RequestHandlerSelectors.any()).paths(PathSelectors.any()).build();
} public ApiInfo apiInfo(){
return new ApiInfoBuilder().build();
}
}

在application启动类添加

@EnableSwagger2

启动页面测试

浏览器中访问http://localhost:8001/swagger-ui.html#/

SpringBoot+SpringCloud+vue+Element开发项目——集成Swagger文档的更多相关文章

  1. SpringBoot+SpringCloud+vue+Element开发项目——集成Druid数据源

    添加依赖 pom.xml <!--druid--> <dependency> <groupId>com.alibaba</groupId> <ar ...

  2. SpringBoot+SpringCloud+vue+Element开发项目——集成MyBatis框架

    添加mybatis-spring-boot-starter依赖 pox.xml <!--mybatis--> <dependency> <groupId>org.m ...

  3. SpringBoot+SpringCloud+vue+Element开发项目——搭建开发环境

    1.新建一个项目

  4. SpringBoot+SpringCloud+vue+Element开发项目——数据库设计

    1.用户表(sys_user) CREATE TABLE `sys_user` ( `id` ) NOT NULL AUTO_INCREMENT COMMENT '编号', `name` ) NOT ...

  5. SpringBoot系列:六、集成Swagger文档

    本篇开始介绍Api文档Swagger的集成 一.引入maven依赖 <dependency> <groupId>io.springfox</groupId> < ...

  6. .NET Core基础篇之:集成Swagger文档与自定义Swagger UI

    Swagger大家都不陌生,Swagger (OpenAPI) 是一个与编程语言无关的接口规范,用于描述项目中的 REST API.它的出现主要是节约了开发人员编写接口文档的时间,可以根据项目中的注释 ...

  7. springboot集成swagger文档

    //此处省略springboot创建过程 1.引入swagger相关依赖(2个依赖必须版本相同) <dependency> <groupId>io.springfox</ ...

  8. Spring 5 中函数式web开发中的swagger文档

    Spring 5 中一个非常重要的更新就是增加了响应式web开发WebFlux,并且推荐使用函数式风格(RouterFunction和 HandlerFunction)来开发WebFlux.对于之前主 ...

  9. spring boot集成swagger文档

    pom <!-- swagger --> <dependency> <groupId>io.springfox</groupId> <artifa ...

随机推荐

  1. 堆排序Heapsort的Java和C代码

    Heapsort排序思路 将整个数组看作一个二叉树heap, 下标0为堆顶层, 下标1, 2为次顶层, 然后每层就是"3,4,5,6", "7, 8, 9, 10, 11 ...

  2. Intellij idea 告警:URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs)

    URI is not registered (Settings | Languages & Frameworks | Schemas and DTDs) 一.快捷键方式 鼠标移动到出错的的地方 ...

  3. ISO/IEC 9899:2011 条款6.10.3——宏替换

    6.10.3 宏替换 约束 1.两个替换列表是相同的,当且仅当两个替换列表中的预处理符记都具有相同的数.次序.拼写,以及空白分隔符,这里所有的空白分隔符都认为是相同的. 2.当前被定义为一个类似对象的 ...

  4. Sword libcurl库CURLE_COULDNT_CONNECT错误

    CURL: CURLE_COULDNT_CONNECT问题分析 测试环境描述在使用libcurl写http客户端进行压力测试的时候会遇到curl_easy_perform()返回CURLE_COULD ...

  5. 泡泡一分钟:Learning Motion Planning Policies in Uncertain Environments through Repeated Task Executions

    张宁  Learning Motion Planning Policies in Uncertain Environments through Repeated Task Executions 通过重 ...

  6. RSA 签名、验证、加密、解密帮助类

    import java.io.IOException; import java.security.InvalidKeyException; import java.security.KeyFactor ...

  7. 【linux基础err】bash: cannot create temp file for here-document: No space left on device

    博主的device还有剩余空间也出现了这个问题,不知是什么原因,不过删除一些无用的内容,或者将某些有用的内容移动到其他硬盘,之后就可以正常使用了. 参考: 1. cannot create temp ...

  8. [LeetCode] 66. Plus One 加一

    Given a non-empty array of digits representing a non-negative integer, plus one to the integer. The ...

  9. [LeetCode] 129. Sum Root to Leaf Numbers 求根到叶节点数字之和

    Given a binary tree containing digits from 0-9 only, each root-to-leaf path could represent a number ...

  10. upgrade rubygems

    gem install rubygems-update update_rubygems gem update --system gem update