Spring boot 禁用招摇过市ui时更改默认erorr消息
我正试图根据我的Spring boot 禁用招摇过市ui时更改默认erorr消息,spring-boot,swagger-ui,swagger-2.0,Spring Boot,Swagger Ui,Swagger 2.0,我正试图根据我的应用程序local.properties中的标志手动禁用swagger。要禁用的代码是: @Bean Docket localApi() { return new Docket(DocumentationType.SWAGGER_2) .enable(swaggerEnabled) .ignoredParameterTypes(MetaClass.class, MetaMethod.class) .apiInfo(metaData()) .
应用程序local.properties
中的标志手动禁用swagger。要禁用的代码是:
@Bean
Docket localApi() {
return new Docket(DocumentationType.SWAGGER_2)
.enable(swaggerEnabled)
.ignoredParameterTypes(MetaClass.class, MetaMethod.class)
.apiInfo(metaData())
.select()
.build()
}
swaggerEnabled
是布尔标志。如果标志为false,则会禁用UI。但是,当我转到时,将显示默认消息:
我也想这么做,但我没能做到,所以我使用ConditionalOnExpression注释来禁用swagger,消息不再显示
@Configuration
@ConditionalOnExpression(value = "${useSwagger:false}")
@EnableSwagger2
public class SwaggerConfig implements WebMvcConfigurer {
...
}