当前位置: 首页 > news >正文

go语言网站开发厦门效果图制作公司

go语言网站开发,厦门效果图制作公司,iphone怎么开通互联网,6种常见的网页布局类型需求: 生产环境下,需要关闭swagger配置,避免接口暴露。 方法: 1、使用注解Value() 2、使用注解Profile({“dev”,“test”}) 表示在开发或测试环境开启,而在生产关闭。 3、使用注解ConditionalOnProperty(name “s…

需求:

生产环境下,需要关闭swagger配置,避免接口暴露。

方法:

1、使用注解@Value()
2、使用注解@Profile({“dev”,“test”}) 表示在开发或测试环境开启,而在生产关闭。
3、使用注解@ConditionalOnProperty(name = “swagger.enable”, havingValue = “true”) 然后在测试配置或者开发配置中 添加 swagger.enable = true 即可开启,生产环境不填则默认关闭Swagger。

方法一:使用注解@Value()

在Swagger2Config类里添加;
并需要在配置文件里添加一个swagger.enable属性,根据不同的application-xx.yml进行动态插入true或false即可。

@Configuration
@EnableSwagger2
public class Swagger2Config {@Value("${swagger.enable}")private Boolean enable;@Beanpublic Docket swaggerPersonApi10() {return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("com.unidata.cloud.logservice.api.controller")).paths(PathSelectors.any()).enable(enable)    //配置在该处生效.build().apiInfo(apiInfo());}private ApiInfo apiInfo() {return new ApiInfoBuilder().version("1.0").title("xx项目:xx平台 Swagger2 文档 API").contact(new Contact("  xx团队", "https://www.xx.com/", "kangjia@xx.com")).description("logservice platform API v1.0").build();}
}

方法二:使用注解@Profile({“dev”,“test”}) 表示在开发或测试环境开启,而在生产关闭。

@Configuration
@EnableSwagger2
@Profile({"local", "dev"})
public class Swagger2Config {@Beanpublic Docket swaggerPersonApi10() {return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("com.unidata.cloud.logservice.api.controller")).paths(PathSelectors.any()).build().apiInfo(apiInfo());}private ApiInfo apiInfo() {return new ApiInfoBuilder().version("1.0").title("xx项目:xx平台 Swagger2 文档 API").contact(new Contact("  xx团队", "https://www.xx.com/", "kangjia@xx.com")).description("logservice platform API v1.0").build();}
}

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

1、使用注解 @ConditionalOnProperty(name = “swagger.enable”, havingValue = “true”)

@Configuration
@EnableSwagger2
//@ConditionalOnProperty(name ="enabled" ,prefix = "swagger",havingValue = "true",matchIfMissing = true   //matchIfMissing=true :为空则设为true,不合理
@ConditionalOnProperty(name = “swagger.enable”, havingValue =true)
public class Swagger2Config {@Beanpublic Docket swaggerPersonApi10() {return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.basePackage("com.unidata.cloud.logservice.api.controller")).paths(PathSelectors.any()).enable(enable).build().apiInfo(apiInfo());}private ApiInfo apiInfo() {return new ApiInfoBuilder().version("1.0").title("xx项目:xx平台 Swagger2 文档 API").contact(new Contact("  xx团队", "https://www.xxx.com/", "kangjia@xxx.com")).description("logservice platform API v1.0").build();}
}

2、然后在测试配置或者开发配置中 添加 swagger.enable = true 即可开启,生产环境不写该配置则默认关闭Swagger。

#Swagger lock
swagger:    enabled: true

参考链接:https://www.dandelioncloud.cn/article/details/1593427183718813697

http://www.yayakq.cn/news/53946/

相关文章:

  • 集团网站 wordpress长沙计算机培训机构排名前十
  • 各大网站开发的区块链wordpress制作培训网站
  • 好的做网站的公司有哪些哪里学做网站
  • 做网站建设需要什么资质实训做网站收获
  • 免费建立手机网站吗做外贸英文网站
  • 网站点击弹出下载框 怎么做的国家企业信息公示(全国)
  • 网站icp备案条件请别人做网站有风险吗
  • 一站式平台网站开发技术郑州app开发制作
  • 装修效果图网站推荐大型门户网站建设效果怎么样
  • 用dw怎么做用户登录页面的网站一搜网站制作
  • 艺纵网站建设建立个人视频播放网站
  • 文网站建设费用计入什么科目北京外包公司有哪些
  • 雕刻机做外贸都是哪些网站怎么上线网站
  • 花都做网站公司云服务器做视频网站
  • 怎样提高网站的流量哪个网站可以做免费商业推广
  • 百度推广怎么找客户seo技术培训广东
  • 佛山自助建站系统ppt模板去哪个网站下载
  • 做电影网站的资源从哪里换手机网站存储登录信息
  • 外贸自建站平台怎么找织梦网站手机版端设置
  • 有域名怎样建设网站用dw设计网站怎么做
  • 金融网站怎么做的青海建设厅职称网站
  • 黄山北京网站建设湖州 网站建设公司
  • 网站是做后台好还是做前台好wordpress添加百度统计
  • 视频网站的建设一站式网站建设方案
  • 网站建设炎陵wordpress 房产
  • 北京公司建网站要多少费用网站建设及数据分析
  • 天水网站建设公司对于政务网站建设的建议
  • 网站后台怎么挂广告 怎么做门户网站包括哪些
  • 北京网站设计公司济南兴田德润团队怎么样wordpress菜单出不来
  • 温州微网站建站系统破解源码