swagger2使用

添加依赖

<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>RELEASE</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>

创建Swagger2 类 位于启动类同一目录下
@Configuration
@EnableSwagger2
public class Swagger2 {

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.basePackage("com.boot.controller"))
.paths(PathSelectors.any()).build();
}

private ApiInfo apiInfo() {
return new ApiInfoBuilder()
// 设置页面标题
.title("使用swagger2构建短视频后端api接口文档")
// 设置联系人
.contact(new Contact("imooc-风间影月", "http://www.imooc.com", "imooc@163.com"))
// 描述
.description("欢迎访问短视频接口文档,这里是描述信息")
// 定义版本号
.version("1.0").build();
}
}

相关注解


 

 

 
 

posted on 2019-05-10 14:54  寂寞一沙洲  阅读(153)  评论(0编辑  收藏  举报

导航