1.maven dependency:pom.xml
guava包是因为兼容问题
2.配置configer.java
@Configuration
@EnableSwagger2
public class Swagger2Configuration {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.withClassAnnotation(Api.class))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("boss接口文档")
.description("boss相关接口的文档")
.termsOfServiceUrl("localhost:9090/")
.version("1.0")
.build();
}
}
3.在controller类上添加@Api