1. 在class中 @Configuration //配置是否开启swagger的访问的方式一,动态读取无法使用,@active@ //@Profile({"dev", "test", "local", "uat-local"}) //配置是否开启swagger的访问的方式二,要在yml中添加对应配置 @ConditionalOnProperty(name = "swagger.enable", havingValue = "true") @EnableSwagger2 //Enable swagger 2.0 spec public class SwaggerConfig { 2. 在yml文件中 # 是否启用swagger,true则启用 swagger: enable: true
spring: profiles: active: @active@
# 是否启用swagger,true则启用 swagger: enable: true
@EnableSwagger2 public class Application
原文:https://www.cnblogs.com/weijs/p/14153363.html