Swagger 是一款目前世界最流行的API管理工具
官网
- Swagger
- Swagger Annotation
集成步骤
- 在项目 pom 中引入以下依赖
1 2 3 4 5 6 7 8 9 10
|
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.7.0</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.7.0</version>
</dependency>
|
- 在项目中配置 Swagger
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
|
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).apiInfo(apiInfo()).select()
.apis(RequestHandlerSelectors.any())
.paths(or(regex("/api/.*"))).build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("轻实训-移动端 API").version("1.0").build();
}
}
|
近期评论