3、运行
2、配置
@Configuration //托管给spring @EnableSwagger2 //开启swagger功能的注解 public class SwaggerConfig { @Bean public Docket createRestApi(){ //版本类型是swagger2 return new Docket(DocumentationType.SWAGGER_2) //通过调用自定义方法apiInfo,获得文档的主要信息 .apiInfo(apiInfo()) .select() .paths(Predicates.not(PathSelectors.regex("/admin/.*"))) .paths(Predicates.not(PathSelectors.regex("/error.*"))) // .apis(RequestHandlerSelectors.basePackage("com.atguigu"))//扫描该包下面的API注解 // .paths(PathSelectors.any()) .build(); } /** * 创建该API的基本信息(这些基本信息会展现在文档页面中) * 访问地址:http://项目实际地址/swagger-ui.html * @return */ private ApiInfo apiInfo() { return new ApiInfoBuilder() .title("使用Swagger2 构建REST