springboot整合Swagger
作者:
泥煤的嘎嘎 | 来源:发表于
2019-03-31 18:44 被阅读0次
<!--swagger-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<!--swagger UI-->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
/**
* swagger config
*
* @author 伍磊
*/
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//扫描的是自定义Controller的包名 (与下面二选其一 建议单工程下选择扫描包,多工程下选择扫描注解)
.apis(RequestHandlerSelectors.basePackage("com.leiwu.train"))
// 扫描@ApiOperation注解
.apis(RequestHandlerSelectors.withMethodAnnotation(ApiOperation.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.build();
}
}
Swagger-ui的坑-接口无法展开
本文标题:springboot整合Swagger
本文链接:https://www.haomeiwen.com/subject/xcmubqtx.html
网友评论