Ath*_*mas 16 spring-mvc swagger
我正在使用Swagger和Spring MVC.我想在特定环境(如生产)中有选择地禁用招摇.我怎样才能做到这一点?
Dil*_*nan 40
配置swagger spring-mvc插件时,您可以使用enable
基于环境/配置文件等传递布尔值的方法.
@Bean
public SwaggerSpringMvcPlugin customImplementation(){
return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
.apiInfo(apiInfo())
.enable(environmentSpeficicBooleanFlag) //<--- Flag to enable or disable possibly loaded using a property file
.includePatterns(".*pet.*");
}
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用弹簧轮廓
@Bean
@Profile("production")
public SwaggerSpringMvcPlugin customImplementation(){
return new SwaggerSpringMvcPlugin(this.springSwaggerConfig)
.apiInfo(apiInfo())
.enable(false) //<--- Flag set to false in the production profile
.includePatterns(".*pet.*");
}
Run Code Online (Sandbox Code Playgroud)
配置swagger spring-mvc插件时,您可以使用enable
基于环境/配置文件等传递布尔值的方法.
@Bean
public Docket customImplementation(){
return new Docket(SWAGGER_2)
.apiInfo(apiInfo())
.enable(environmentSpeficicBooleanFlag) //<--- Flag to enable or disable possibly loaded using a property file
.includePatterns(".*pet.*");
}
Run Code Online (Sandbox Code Playgroud)
另一种方法是使用弹簧轮廓
@Bean
@Profile("production")
public Docket customImplementation(){
return new Docket(SWAGGER_2)
.apiInfo(apiInfo())
.enable(false) //<--- Flag set to false in the production profile
.includePatterns(".*pet.*");
}
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
17002 次 |
最近记录: |