package nuc.eduservice.config;
import com.google.common.base.Predicates;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
@Configuration
public class SwaggerConfig {
@Bean
public Docket Docket(){
//指定springfox里用swagger2
Docket docket = new Docket(DocumentationType.SWAGGER_2);
ApiInfo apiInfo = new ApiInfoBuilder()
.contact(
//用于编写文档基本信息
new Contact(
"中北大学软件学院",
"http://ss.nuc.edu.cn/",
"19130415641@nuc.edu.cn")
)
.title("swagger-ui文档")
.description("描述内容")
.version("1.2")
.build();
docket.apiInfo(apiInfo);
//构建选择器
docket.select()
//扫描文件路径
.apis(RequestHandlerSelectors.basePackage("nuc.eduservice.controller")
)
//用于用于指定访问路径
.paths(
Predicates.or(
PathSelectors.regex("/swagger/.*"),
PathSelectors.regex("/.*")
)
)
.build();
return docket;
}
}
配置swagger的配置类模板
最新推荐文章于 2023-10-23 21:25:45 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)