程序员最近都爱上了这个网站  程序员们快来瞅瞅吧!  it98k网:it98k.com

本站消息

站长简介/公众号

  出租广告位,需要合作请联系站长


+关注
已关注

分类  

java(0)

标签  

暂无标签

日期归档  

2023-06(2)

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

发布于2022-08-02 01:34     阅读(1552)     评论(0)     点赞(19)     收藏(5)


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

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

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

  1. <dependency>
  2. <groupId>io.springfox</groupId>
  3. <artifactId>springfox-swagger2</artifactId>
  4. <version>2.9.2</version>
  5. <exclusions>
  6. <exclusion>
  7. <artifactId>byte-buddy</artifactId>
  8. <groupId>net.bytebuddy</groupId>
  9. </exclusion>
  10. </exclusions>
  11. </dependency>

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

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

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

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

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

  1. @EnableAsync
  2. @EnableWebMvc
  3. @ServletComponentScan
  4. @ComponentScan(basePackages = {"com.xmair.restapi","com.xmair.core.service"})
  5. @MapperScan("com.xmair.core.mapper")
  6. public class MFISRestAPIApplication {
  7. public static void main(String[] args) {
  8. ConfigurableApplicationContext context = SpringApplication.run(MFISRestAPIApplication.class, args);
  9. }
  10. }

2、WebMvcConfig.java文件加上下面这段:

  1. @Override
  2. public void addResourceHandlers(ResourceHandlerRegistry registry) {
  3. registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");
  4. registry.addResourceHandler("doc.html").addResourceLocations("classpath:/META-INF/resources/");
  5. registry.addResourceHandler("/webjars/**").addResourceLocations("classpath:/META-INF/resources/webjars/");
  6. registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/META-INF/resources/");
  7. }

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

  1. <!-- 使用swagger-bootstrap-ui替换swagger-ui -->
  2. <!--<dependency>-->
  3. <!--<groupId>com.github.xiaoymin</groupId>-->
  4. <!--<artifactId>swagger-bootstrap-ui</artifactId>-->
  5. <!--<version>1.9.2</version>-->
  6. <!--</dependency>-->

4、引入google的guava依赖:

  1. <dependency>
  2. <groupId>com.google.guava</groupId>
  3. <artifactId>guava</artifactId>
  4. <version>25.1-jre</version>
  5. </dependency>

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

  1. <!--<dependency>-->
  2. <!--<groupId>com.google.guava</groupId>-->
  3. <!--<artifactId>guava</artifactId>-->
  4. <!--<version>19.0</version>-->
  5. <!--</dependency>-->

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

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

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

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

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

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

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

原文链接:https://blog.csdn.net/KGzhang/article/details/124837789



所属网站分类: 技术文章 > 博客

作者:java王侯

链接:http://www.javaheidong.com/blog/article/471477/0ac92ce61c9f9aaed373/

来源:java黑洞网

任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任

19 0
收藏该文
已收藏

评论内容:(最多支持255个字符)