Spring Swagger通过注解就可以为我们生成接口文档,十分便捷!
首先,在build.grade配置文件中加入依赖
implementation 'org.apache.kafka:kafka-clients'
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
加入Swagger的配置
/**
* @author linzihao
*/
@Configuration
@EnableSwagger2
@ConditionalOnProperty(prefix = "swagger2", value = {"enable"}, havingValue = "true")
public class Swagger2Config {
//http://localhost:7002/data-vip/doc.html
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2).pathMapping("/").select()
.apis(RequestHandlerSelectors.withClassAnnotation(RestController.class))
.paths(PathSelectors.any())
.build()
.apiInfo(new ApiInfoBuilder()