Java Api 文档

Swagger2

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

配置注入

@Configuration
@EnableSwagger2
public class Swagger2 {
    @Bean
    public Docket createRestApi() {
        return new Docket(DocumentationType.SWAGGER_2)
                .apiInfo(apiInfo())
                .select()
                .apis(RequestHandlerSelectors.basePackage("com"))
                .paths(PathSelectors.any())
                .build();
    }

    private ApiInfo apiInfo() {
        return new ApiInfoBuilder()
                .title("Restful Api | 文档构建")
                .description("更多Spring Boot相关文章请关注:http://www.xxx.com/")
                .termsOfServiceUrl("http://www.xxx.com/")
                .contact(new Contact("abc", "http://www.xxx.com/", "abc@163.com"))
                .version("1.0")
                .build();
    }
}
上一篇:springboot 添加swagger


下一篇:Springboot系列(七) 集成接口文档swagger,使用,测试