面试|springboot启动报错(Failed to start bean ‘documentationPluginsBootstrapper‘)

首先贴一下完整的错误信息:

o.s.b.w.s.c.AnnotationConfigServletWebServerApplicationContext - Exception encountered during context initialization - cancelling refresh attempt: org.springframework.context.ApplicationContextException: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is com.google.common.util.concurrent.ExecutionError: java.lang.NoSuchMethodError: com.google.common.collect.FluentIterable.concat(Ljava/lang/Iterable; Ljava/lang/Iterable; )Lcom/google/common/collect/FluentIterable;

这个问题网上搜出来基本都是springboot版本和swagger版本之间的冲突。下面是我工程的swagger2版本(2.9.2):
io.springfox springfox-swagger2 2.9.2 byte-buddy net.bytebuddy

首先分享两篇参考性比较大的文章:
(已解决)Failed to start bean ‘documentationPluginsBootstrapper’_FFFPAG的博客-CSDN博客
解决 高版本SpringBoot整合Swagger 启动报错Failed to start bean ‘documentationPluginsBootstrapper‘ 问题_摸鱼佬的博客-CSDN博客
然后就是本人的一些解决方案(按照上面的文章):
1、启动类加上@EnableWebMvc(不过感觉没啥用):
@EnableAsync @EnableWebMvc @ServletComponentScan @ComponentScan(basePackages = {"com.xmair.restapi","com.xmair.core.service"}) @MapperScan("com.xmair.core.mapper") public class MFISRestAPIApplication { public static void main(String[] args) { ConfigurableApplicationContext context = SpringApplication.run(MFISRestAPIApplication.class, args); } }

2、WebMvcConfig.java文件加上下面这段:
@Override public void addResourceHandlers(ResourceHandlerRegistry registry) { registry.addResourceHandler("/**").addResourceLocations("classpath:/static/"); registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/"); registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/"); registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/"); }

3、pom文件注释掉下面的依赖:

4、引入google的guava依赖:
com.google.guava guava 25.1-jre

不过做了上述修改后仍然会报同样的错误,最后发现是guava依赖冲突了,把原先的版本去掉:

终于把问题解决了,工程也启起来了!!!!!!!
不过网上有博客说可以在配置文件application.yml添加ant_path_matcher:
spring: mvc: pathmatch: matching-strategy: ant_path_matcher

不过我工程里面配置文件不是这么写的,相应的办法是在properties文件加上:
spring.mvc.pathmatch.matching-strategy=ant-path-matcher

我在解决过程中尝试过这个方法,不过同样的问题还是存在,最后我把它去掉了。
【面试|springboot启动报错(Failed to start bean ‘documentationPluginsBootstrapper‘)】以上,就是我解决本次问题的流水账……

    推荐阅读