6.使用swagger在线生成接口文档
2019-03-24 本文已影响0人
王杰磊
使用方法
- 在pom.xml中添加依赖
<dependency>
<groupId>com.spring4all</groupId>
<artifactId>swagger-spring-boot-starter</artifactId>
<version>1.8.0.RELEASE</version>
</dependency>
- 在应用主类中加注解
@EnableSwagger2Doc
- 在application.properties文件中配置参数
#swagger配置
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/dyc87112/spring-boot-starter-swagger
swagger.contact.name=wjl
swagger.contact.url=https://www.jianshu.com/u/a32873d23481
swagger.contact.email=1433686098@qq.com
swagger.base-package=com.spring.mybatis.springbootdemo.controller
swagger.base-path=/**
swagger.exclude-path=/error, /ops/**
- 运行主类,在浏览器中输入http://localhost:8080/swagger-ui.html#/查看效果
image.png