详细使用教程
依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.8.0</version>
</dependency>
<!-- https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.8.0</version>
</dependency>
配置类
@Configuration
@EnableSwagger2
public class SwaggerConfig
{
public Docket createApi(){
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.miao.springbootswagger"))
.paths(PathSelectors.any())
.build();
}
// 创建api的基本信息
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("springBoot 整合 Swagger2 实例")
.description("更多技术内容分享见博客:https://blog.csdn.net/qq_24871519")
.termsOfServiceUrl("https://blog.csdn.net/qq_24871519")
.version("1.0")
.build();
}
}