当前位置:网站首页 > R语言数据分析 > 正文

swagger2关闭配置(swagger怎么配置)



禁用方法2:使用注解@ConditionalOnProperty(name = "swagger.enable", havingValue = "true") 然后在测试配置或者开发配置中 添加 swagger.enable = true 即可开启,生产环境不填则默认关闭Swagger.

如方法1:

package com.left;

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.spi.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;

/
* <pre>
* @author : orange
* e-mail : @.com
* time : 2018/8/27 14:49
* desc : swagger配置
* version: 1.0
* </pre>
*/
@Configuration
@EnableSwagger2
@Profile({"dev","test"})
public class Swagger2 {

@Bean
public Docket restApi(){
return new Docket(DocumentationType.SWAGGER_2)
.select()
.apis(RequestHandlerSelectors.basePackage("com.left.controller"))
.paths(PathSelectors.any())
.build()
.apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder().title("springboot整合swagger2")
.description("springboot整合swagger2")
.termsOfServiceUrl("https://blog.csdn.net/weixin_")
.version("1.0")
.build();
}

}
结果:

开发环境可以正常访问

到此这篇swagger2关闭配置(swagger怎么配置)的文章就介绍到这了,更多相关内容请继续浏览下面的相关 推荐文章,希望大家都能在编程的领域有一番成就!

版权声明


相关文章:

  • resnet50和resnet18(resnet50和resnet18速度)2025-02-10 15:36:08
  • redhat操作系统(redhat操作系统安装步骤)2025-02-10 15:36:08
  • expatrio客服(expatrio客服邮箱)2025-02-10 15:36:08
  • 华为ensp模拟器怎么使用(ensp模拟器hybrid)2025-02-10 15:36:08
  • lvcreate命令参数(lvresize命令)2025-02-10 15:36:08
  • Oracle查看锁表记录(oracle如何看锁表)2025-02-10 15:36:08
  • uchar是什么意思(uchar j什么意思)2025-02-10 15:36:08
  • srore的名词(irregular名词)2025-02-10 15:36:08
  • pointnet论文解读(pointpillars论文)2025-02-10 15:36:08
  • drury 怎么读(Drury怎么读)2025-02-10 15:36:08
  • 全屏图片