springboot 配置 swagger
就肥藏简单的,你跟我做就好了
首先,pom文件新增依赖
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.6.1</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.6.1</version>
</dependency>
最后,创建一个丝袜哥配置文件
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi(){
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any()).build();
}
private ApiInfo apiInfo(){
return new ApiInfoBuilder()
.title("*** API DOC")
.description("This is a restful api document of ***.")
.version("1.0")
.build();
}
}
好啦~ vans啦~
打开你的http://localhost:8086/swagger-ui.html
瞅一眼~
是不是就非常简单???跟白捡的似的~