1.pom.xml

<!--swagger2-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
</exclusion>
</exclusions>
</dependency>
<!--下面的不添加会导致访问报404-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
<!--swagger2密码-->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-security</artifactId>
</dependency>
application.properties添加swagger访问密码:

security.basic.enabled=true
security.basic.path=/swagger-ui.html
security.user.name=admin
security.user.password=123456

2.swagger配置类

参考:http://blog.didispace.com/springbootswagger2/

3.生成离线文档:

使用springfox-staticdocs生成swagger离线api文档附带源码

4.项目使用demo:

responseMessages.add(new ResponseMessageBuilder().code(999).message("未知异常").responseModel(new ModelRef(error)).build());
return
new Docket(DocumentationType.SWAGGER_2).
apiInfo(buildApiInfo())
.tags(new Tag("tag1", "接口类描述1"),
new Tag("tag2", "接口类描述2")).
select().
apis(RequestHandlerSelectors.
basePackage(swaggerBasePackage)).
paths(PathSelectors.any()).
build()
.useDefaultResponseMessages(false)
.globalResponseMessage(RequestMethod.GET, responseMessages)
@Api(tags = {"tag1"})
@RestController
@RequestMapping(value = "test")
public class ResourceApi { //...some code... /**
* @author Jill
*/
@PostMapping
@ApiOperation("查询资源列表接口")
public Response<Object> getInfoList(@RequestBody @Valid
@ApiParam(name = "查询条件", value = "查询条件")
SearchVO vo) {

swagger配置的更多相关文章

  1. 一、Swagger配置

    一.Swagger配置 1.注解不显示 SwaggerConfig文件下   //c.IncludeXmlComments(GetXmlCommentsPath()):  内下面添加: c.Inclu ...

  2. Spring Boot项目简单上手+swagger配置+项目发布(可能是史上最详细的)

    Spring Boot项目简单上手+swagger配置 1.项目实践 项目结构图 项目整体分为四部分:1.source code 2.sql-mapper 3.application.properti ...

  3. swagger 配置- ssm

    swagger 配置 - ssm swagger 是一个用来看接口的工具,具体效果如下,这里用的是swagger2 1.porm.xml <dependency> <groupId& ...

  4. 尝试从零开始构建我的商城 (二) :使用JWT保护我们的信息安全,完善Swagger配置

    前言 GitHub地址 https://github.com/yingpanwang/MyShop/tree/dev_jwt 此文对应分支 dev_jwt 此文目的 上一篇文章中,我们使用Abp vN ...

  5. webapi Swagger 配置 services.BuildServiceProvider() 报警 ASP0000 问题处理

    问题起源 网上的常见配置 Swagger 配置 在Startup类的 ConfigureServices 使用 services.BuildServiceProvider() ,其中有段代码如下: v ...

  6. 《Asp.Net Core3 + Vue3入坑教程》-Net Core项目搭建与Swagger配置步骤

    简介 <Asp.Net Core3 + Vue3入坑教程> 此教程仅适合新手入门或者前后端分离尝试者.可以根据图文一步一步进操作编码也可以选择直接查看源码.每一篇文章都有对应的源码 教程后 ...

  7. SpringBoot初探之Swagger配置

    Swagger是一个用于描述和测试restful接口的工具,只要在定义restful接口时增加一些类和方法的描述注解,通过很简单的配置就可以得到一个展示接口定义页面,也可以在页面上设置参数提交测试接口 ...

  8. swagger配置和简单使用

    说明:本地环境idea + maven3.5 + springboot2.0.0 + springfox-swagger2 2.8.0  + springfox-swagger-ui 2.8.0 +  ...

  9. .net core web api swagger 配置笔记

    参考网址: --配置步骤见如下链接https://docs.microsoft.com/zh-cn/aspnet/core/tutorials/web-api-help-pages-using-swa ...

随机推荐

  1. Loj 2536 解锁屏幕

    Loj 2536 解锁屏幕 状态比较显然的状压 \(dp\) ,设 \(f[S][i]\) 表示连接 \(S\) 集合中的点,最后到的点是 \(i\) 的方案数. 转移时,枚举一个 \(j\notin ...

  2. Maze dfs倒行

    Pavel loves grid mazes. A grid maze is an n × m rectangle maze where each cell is either empty, or i ...

  3. hdu2080-2081

    hdu2080 计算两点关于原点夹角,数学 #include<stdio.h> #include<math.h> double len(double x1,double y1, ...

  4. <ul><li>

    ☆ <ul><li> 1. li是不能单独使用,必须在于ul之中的. 2. ul是块级元素,能直接定义宽高,而li是行级元素,不能直接定义 高. 3. li组 只能写在ul之中 ...

  5. (转)C++ 容器及选用总结

    目录 ==================================================== 第一章 容器 第二章 Vector和string 第三章 关联容器 第四章 迭代器 第五 ...

  6. 【java规则引擎】《Drools7.0.0.Final规则引擎教程》第4章 4.2 activation-group& dialect& date-effective

    转载至:https://blog.csdn.net/wo541075754/article/details/75511887 activation-group 该属性将若干个规则划分成一个组,统一命名 ...

  7. android 图片解码显示流程

    版权声明:本文为博主原创文章,未经博主同意不得转载. https://blog.csdn.net/jingxia2008/article/details/32327699 问题来源 android 能 ...

  8. u-boot分析

    4.Bootloader:u-boot.2009.08分析与移植4.1:分析u-boot根文件夹下的Makefile,能够看到uboot编译的顺序例如以下,由此可知编译运行的第一个文件是cpu/$(C ...

  9. IDEA永久激活

    对于java开发者来说,idea无疑是使用最广泛最得力的开发工具(没有之一):网上的激活教程也是非常多,这里昌昌也再提供一份更加详细的激活教程,为那些刚入门的开发者们做出一点自己的贡献,对于使用有效期 ...

  10. protobuf生成

    1,文件路径匹配好在src/main/proto下面 https://blog.csdn.net/u010939285/article/details/78538927