springboot集成swagger 時報o.s.web.servlet.PageNotFound :No mapping for GET異常

問題如下
問題
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{
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章