• 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; 
    
    • 1
    • 2
    • 3
    • 4

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

    
        io.springfox
        springfox-swagger2
        2.9.2
        
            
                byte-buddy
                net.bytebuddy
            
        
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

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

    (已解决)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);
        }
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10

    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/");
    }
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

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

    
    
        
        
        
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    4、引入google的guava依赖:

    
       com.google.guava
       guava
       25.1-jre
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

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

    
        
        
        
    
    
    • 1
    • 2
    • 3
    • 4
    • 5

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

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

    spring:
      mvc:
        pathmatch:
          matching-strategy: ant_path_matcher
    
    • 1
    • 2
    • 3
    • 4

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

    spring.mvc.pathmatch.matching-strategy=ant-path-matcher
    
    • 1

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

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

    先自我介绍一下,小编13年上师交大毕业,曾经在小公司待过,去过华为OPPO等大厂,18年进入阿里,直到现在。深知大多数初中级java工程师,想要升技能,往往是需要自己摸索成长或是报班学习,但对于培训机构动则近万元的学费,着实压力不小。自己不成体系的自学效率很低又漫长,而且容易碰到天花板技术停止不前。因此我收集了一份《java开发全套学习资料》送给大家,初衷也很简单,就是希望帮助到想自学又不知道该从何学起的朋友,同时减轻大家的负担。添加下方名片,即可获取全套学习资料哦

  • 相关阅读:
    使用容器快速在阿里云 ECS 多节点上搭建 Citus 12.1 集群
    H5\CSS\JS 盒子拖动mousedown、mousemove、mouseup、pageX、pageY、offsetLeft、offsetTop
    人工神经网络与遗传算法,神经网络和算法的关系
    A Guide to Java HashMap
    Cocos 距离判断和小兵的攻击判定
    数学学习基本理念与方法
    【Linux】内核驱动篇七--设备树
    计算机相关专业是否仍是“万金油”的选择?
    CSS 多按钮根据半圆弧度排列
    进程与线程
  • 原文地址:https://blog.csdn.net/m0_67401270/article/details/126114476