問題如下
springboot啓動的時候 報上述異常
MySwaggerConfig代碼:
@Configuration
@EnableSwagger2 //必須存在
public class MySwaggerConfig extends WebMvcConfigurationSupport{
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any()).build().apiInfo(apiInfo());
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("xxx")
.description("XXX")
.version("1.0.0")
.contact("")
.termsOfServiceUrl("")
.license("")
.licenseUrl("").build();
}
}
解決辦法:
將extends WebMvcConfigurationSupport 改爲implements WebMvcConfigurer
public class MySwaggerConfig implements WebMvcConfigurer{