您的位置:首页 > 编程语言 > Java开发

详解SpringBoot结合swagger2快速生成简单的接口文档

2019-05-12 18:01 1056 查看

1. pom.xml中加入依赖

<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.8.0.RELEASE</version>
</dependency>

2. 在启动类(即带@SpringBootApplication这个注解的类)上添加@EnableSwagger2Doc注解

3. 在application.properties中配置如下

swagger.enabled=true
swagger.title=spring-boot-mybatis module api
swagger.description=Starter for swagger 2.x
swagger.license=Apache License, Version 2.0
swagger.licenseUrl=https://www.apache.org/licenses/LICENSE-2.0.html
swagger.termsOfServiceUrl=https://github.com/pbw123/spring-boot-demo
swagger.contact.name=mqXu
swagger.contact.url=https://www.jianshu.com/u/2f60beddf923
swagger.contact.email=2635225112@qq.com
swagger.base-package=com.springboot.mybatis.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**

经我多次尝试application.properties中不加任何swagger配置也可生成文档进行正常测试

另一种用swagger自动生成文档的方式请前往

以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持脚本之家。

您可能感兴趣的文章:

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: