springboot启动报错:Failed to start bean ‘documentationPluginsBootstrapper‘

时间:2025-04-13 06:58:43

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

 - Exception encountered during context initialization - cancelling refresh attempt: 
: Failed to start bean 'documentationPluginsBootstrapper'; nested exception is 
: : 
(Ljava/lang/Iterable;Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable; 

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

<dependency>
    <groupId></groupId>
    <artifactId>springfox-swagger2</artifactId>
    <version>2.9.2</version>
    <exclusions>
        <exclusion>
            <artifactId>byte-buddy</artifactId>
            <groupId></groupId>
        </exclusion>
    </exclusions>
</dependency>

首先分享两篇参考性比较大的文章:

(已解决)Failed to start bean ‘documentationPluginsBootstrapper’_FFFPAG的博客-****博客

解决 高版本SpringBoot整合Swagger 启动报错Failed to start bean ‘documentationPluginsBootstrapper‘ 问题_摸鱼佬的博客-****博客

然后就是本人的一些解决方案(按照上面的文章):

1、启动类加上@EnableWebMvc(不过感觉没啥用):

@EnableAsync
@EnableWebMvc
@ServletComponentScan
@ComponentScan(basePackages = {"",""})
@MapperScan("")
public class MFISRestAPIApplication {
    public static void main(String[] args) {
        ConfigurableApplicationContext context = (, args);
    }
}

2、文件加上下面这段:

@Override
public void addResourceHandlers(ResourceHandlerRegistry registry) {
        ("/**").addResourceLocations("classpath:/static/");
        ("").addResourceLocations("classpath:/META-INF/resources/");
        ("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
        ("").addResourceLocations("classpath:/META-INF/resources/");
}

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

<!-- 使用swagger-bootstrap-ui替换swagger-ui -->
<!--<dependency>-->
    <!--<groupId></groupId>-->
    <!--<artifactId>swagger-bootstrap-ui</artifactId>-->
    <!--<version>1.9.2</version>-->
<!--</dependency>-->

4、引入google的guava依赖:

<dependency>
   <groupId></groupId>
   <artifactId>guava</artifactId>
   <version>25.1-jre</version>
</dependency>

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

<!--<dependency>-->
    <!--<groupId></groupId>-->
    <!--<artifactId>guava</artifactId>-->
    <!--<version>19.0</version>-->
<!--</dependency>-->

终于把问题解决了,工程也启起来了!!!!!!!

不过网上有博客说可以在配置文件添加ant_path_matcher:

spring:
  mvc:
    pathmatch:
      matching-strategy: ant_path_matcher

不过我工程里面配置文件不是这么写的,相应的办法是在properties文件加上:

-strategy=ant-path-matcher

我在解决过程中尝试过这个方法,不过同样的问题还是存在,最后我把它去掉了。

以上,就是我解决本次问题的流水账……