发布于2022-08-02 01:34 阅读(1552) 评论(0) 点赞(19) 收藏(5)
首先贴一下完整的错误信息:
- 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):
- <dependency>
- <groupId>io.springfox</groupId>
- <artifactId>springfox-swagger2</artifactId>
- <version>2.9.2</version>
- <exclusions>
- <exclusion>
- <artifactId>byte-buddy</artifactId>
- <groupId>net.bytebuddy</groupId>
- </exclusion>
- </exclusions>
- </dependency>
首先分享两篇参考性比较大的文章:
(已解决)Failed to start bean ‘documentationPluginsBootstrapper’_FFFPAG的博客-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文件注释掉下面的依赖:
- <!-- 使用swagger-bootstrap-ui替换swagger-ui -->
- <!--<dependency>-->
- <!--<groupId>com.github.xiaoymin</groupId>-->
- <!--<artifactId>swagger-bootstrap-ui</artifactId>-->
- <!--<version>1.9.2</version>-->
- <!--</dependency>-->
4、引入google的guava依赖:
- <dependency>
- <groupId>com.google.guava</groupId>
- <artifactId>guava</artifactId>
- <version>25.1-jre</version>
- </dependency>
不过做了上述修改后仍然会报同样的错误,最后发现是guava依赖冲突了,把原先的版本去掉:
- <!--<dependency>-->
- <!--<groupId>com.google.guava</groupId>-->
- <!--<artifactId>guava</artifactId>-->
- <!--<version>19.0</version>-->
- <!--</dependency>-->
终于把问题解决了,工程也启起来了!!!!!!!
不过网上有博客说可以在配置文件application.yml添加ant_path_matcher:
- spring:
- mvc:
- pathmatch:
- 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黑洞网
任何形式的转载都请注明出处,如有侵权 一经发现 必将追究其法律责任
昵称:
评论内容:(最多支持255个字符)
---无人问津也好,技不如人也罢,你都要试着安静下来,去做自己该做的事,而不是让内心的烦躁、焦虑,坏掉你本来就不多的热情和定力
Copyright © 2018-2021 java黑洞网 All Rights Reserved 版权所有,并保留所有权利。京ICP备18063182号-2
投诉与举报,广告合作请联系vgs_info@163.com或QQ3083709327
免责声明:网站文章均由用户上传,仅供读者学习交流使用,禁止用做商业用途。若文章涉及色情,反动,侵权等违法信息,请向我们举报,一经核实我们会立即删除!