1. 在Swagger2配置类中加入如下注解
@ConditionalOnProperty(prefix = "swagger2",value = {"enable"},havingValue = "true")
@Configuration
@ConditionalOnProperty(prefix = "swagger2",value = {"enable"},havingValue = "true")
@EnableSwagger2
public class Swagger2 {
@Bean
public Docket createRestApi() {
return new Docket(DocumentationType.SWAGGER_2).select()
// 指定controller存放的目录路径
.apis(RequestHandlerSelectors.basePackage("com.controller"))
.paths(PathSelectors.any()).build();
}
}
2.修改配置文件
swagger2.enable: true
网友评论