swagger 是一个Rest APIs文档生成工具。
1.swagger可是直接嵌入到项目中,在接口上加上接口的注解描述,自动生成接口文档。
2.很方便管理和测试后台接口。
下面是Swagger的基础配置
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage(“com.memoire.demo(java下的资源包名称)”))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("我的Api Documentation") .description("我的Api文档") .termsOfServiceUrl("http://www.baidu.com/") .contact(new Contact("研发部", "http://www.baidu.com/page/aboutWe.html", "")) .version("1.0") .build(); }
}
这样 我的项目com.zqc.springboot下的接口就会全部暴露个Swagger 然后就可以很方便的管理了
这样我的接口就都暴露在了swagger下。 第一次发文章 说的不详细欢迎提问!