1.配置
1)application.yml文件配置
path 这里写到controller层,从java目录开始写
2)pom文件配置
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
<exclusions>
<exclusion>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-models</artifactId>
<version>1.5.21</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- swagger2 增强UI ,拥有好看的界面, 和接口分组,排序等功能,如不引用可自行删除 -->
<dependency>
<groupId>com.github.xiaoymin</groupId>
<artifactId>swagger-bootstrap-ui</artifactId>
<version>1.8.8</version>
</dependency>
- 使用
@Api(tags = "描述信息")
@ApiSort(value = 2) //swaggerUI界面上的位置为第二条
@restController
@RequestMapping("url")
public class UseSwagger{
@ApiOperation(value = "描述信息", position = 1)
@ApiImplicitParams({
@ApiImplicitParam(name = "接口名字", value = "接口名字解释", dataType = "参数类型", paramType = "body", required = false),
@ApiImplicitParam(name = "接口名字", value = "接口名字解释", dataType = "参数类型", paramType = "body", required = false),
@ApiImplicitParam(name = "接口名字", value = "接口名字解释", dataType = "参数类型", paramType = "body", required = false)
})
//paramType : 若参数为对象,一般使用body;若为单个字段,则为query
@RequestMapping("url")
public Object test{
}
}