@Configuration
@EnableSwagger2 // swagger类添加这个注解
public class Swagger2Config {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
//为当前包下的controller生成api文档
.apis(RequestHandlerSelectors.basePackage("com.lh.server.controller"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
//设置文档信息
return new ApiInfoBuilder()
.title("项目接口文档")
.description("项目接口文档")
.contact(new Contact("xxxx", "http:localhost:8081/doc.html",
"xxxx@xxxx.com"))
.version("1.0")
.build();
}
}
swagger配置类
最新推荐文章于 2024-04-09 19:21:30 发布