springboot整合swagger笔记
首先,在pom.xml中添加依赖
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.</version>
</dependency>
然后在启动类中添加Swagger2 java配置文件
package com.example.demomybatis; import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.context.annotation.Bean;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
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; @SpringBootApplication
@EnableSwagger2
@MapperScan("com.example.demomybatis.mapper")
public class DemoMybatisApplication { public static void main(String[] args) {
SpringApplication.run(DemoMybatisApplication.class, args);
} @Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.example.demomybatis.Controller"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
} private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("测试接口平台API")
.description("cathy demo API.")
.termsOfServiceUrl("Terms of service")
.contact(new Contact("ylw","",""))
.version("1.0")
.build();
}
}
在上面这个代码中,为swagger加入的部分是

最后,访问http://localhost:8080/swagger-ui.html

springboot整合swagger笔记的更多相关文章
- SpringBoot 整合swagger
springBoot 整合swagger 1.pom.xml 配置 <dependency> <groupId>io.springfox</groupId> < ...
- SpringBoot整合Swagger和Actuator
前言 本篇文章主要介绍的是SpringBoot整合Swagger(API文档生成框架)和SpringBoot整合Actuator(项目监控)使用教程. SpringBoot整合Swagger 说明:如 ...
- 【SpringBoot | Swagger】SpringBoot整合Swagger
SpringBoot整合Swagger 1. 什么是Swagger Swagger 是一个规范和完整的框架,用于生成.描述.调用和可视化 RESTful 风格的 Web 服务.简单说就是项目跑起来了, ...
- springboot整合swagger。完爆前后端调试
web接口开发时在调试阶段最麻烦的就是参数调试,前端需要咨询后端.后端有时候自己也不是很了解.这时候就会造成调试一次接口就需要看一次代码.Swagger帮我们解决对接的麻烦 springboot接入s ...
- SpringBoot整合Swagger实战
源码地址:https://github.com/laolunsi/spring-boot-examples 目前SpringBoot常被用于开发Java Web应用,特别是前后端分离项目.为方便前后端 ...
- SpringBoot整合Swagger测试api构建
@Author:SimpleWu 什么是Swagger? Swagger是什么:THE WORLD'S MOST POPULAR API TOOLING 根据官网的介绍: Swagger Inspec ...
- SpringBoot整合swagger
Swagger使用 Swagger有什么用? swagger是一个流行的API开发框架,这个框架以“开放API声明”(OpenAPI Specification,OAS)为基础, 对整个API的开发周 ...
- springboot入门系列(二):SpringBoot整合Swagger
上一篇<简单搭建SpringBoot项目>讲了简单的搭建SpringBoot 项目,而 SpringBoot 和 Swagger-ui 搭配在持续交付的前后端开发中意义重大,Swagger ...
- SpringBoot整合Swagger初探
当下的Web项目大都采用前后端分离+分布式微服务的架构.前后端分离式的开发中,前端开发人员要与后端开发人员协商通信接口,约定接口规范.因此对于开发人员来说能够维持一份及时更新且完整全面的API文档会大 ...
随机推荐
- 理解JavaScript作用域
这是一篇译文,这里贴上译文地址:http://www.zcfy.cc/article/understanding-scope-in-javascript-8213-scotch-4075.html 这 ...
- 让zepto支持ie
找到zepto源码:修改为如下代码: zepto.Z = function(dom, selector) { dom = dom || [] // 支持ie10,主要是支持wp8 if(window. ...
- QBC(Query By Criteria) QBE (Query By Example)
QBC 参考:(Hibernate的QBC查询) //is empty and is not empty @Test public void testQBC(){ Session session = ...
- Oracle:environment variable "PATH" does not exceed the recommended length
今天重新安装oracle11g,突然在检测时报了以下错误: Environment variable: "PATH" - This test checks whether the ...
- 6.Zabbix 3.0 MySQL 监控
请查看我的有道云笔记: http://note.youdao.com/noteshare?id=94cd760a4848939d33892b7464cc0401&sub=8B6EDD27671 ...
- day2 数据结构和一些基础知识
请查看我的云笔记链接: http://note.youdao.com/noteshare?id=4171342601326695ec87866e1cc3e410&sub=20CFB149543 ...
- 一点一点学写Makefile(5)-获取文件所在路径
我们在开发一套代码时,应该保证工程放到任何一个目录中均可以编译成功,但是有时候链接库的时候会造成编译错误,本次就会告诉大家如何动态的获得工程所在的绝对路径 代码下载目录 选择Makefile-5 // ...
- 通过describe命令学习Kubernetes的pod属性详解
我们可以首先使用kubectl get pods命令得到pod列表,比如我们想研究pod nginx-storage-pod的明细: 使用命令kubectl describe pod nginx-st ...
- 转载:em(倍)与px的区别
转载出处:http://www.cnblogs.com/showker/archive/2010/05/24/1742821.html 在国内网站中,包括三大门户,以及“引领”中国网站设计潮流的蓝色理 ...
- WCF思考随笔一: WCF是干什么的?
对于WCF,之前知道是微软新一代开发框架的重要组成部分,是从之前Socket,COM,COM+,.NET Remoting,WebService等等系统内或系统间通讯解决方案发展而来,同时对各种解决方 ...