前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >Maven Helper插件——实现一键Maven依赖冲突问题

Maven Helper插件——实现一键Maven依赖冲突问题

作者头像
朱季谦
发布2022-03-09 17:29:10
7610
发布2022-03-09 17:29:10
举报

业余在一个SpringBoot项目集成Swagger2时,启动过程一直出现以下报错信息——

An attempt was made to call a method that does not exist. The attempt was made from the following location:

springfox.documentation.schema.DefaultModelDependencyProvider.dependentModels(DefaultModelDependencyProvider.java:79)

The following method did not exist:

com.google.common.collect.FluentIterable.concat(Ljava/lang/Iterable;Ljava/lang/Iterable;)Lcom/google/common/collect/FluentIterable;

The method's class, com.google.common.collect.FluentIterable, is available from the following locations:

​ jar:file:/C:/Users/92493/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar!/com/google/common/collect/FluentIterable.class

The class hierarchy was loaded from the following locations:

​ com.google.common.collect.FluentIterable: file:/C:/Users/92493/.m2/repository/com/google/guava/guava/18.0/guava-18.0.jar

Action:

Correct the classpath of your application so that it contains a single, compatible version of com.google.common.collect.FluentIterable

出现这个问题,大概猜测到,应该是Maven依赖冲突导致的,忽然想到,是否有可以检查maven依赖冲突的插件呢,一查发现还真有,而且极方便。

这个Idea插件,叫Maven Helper,根据File -> Settings -> Plugins -> Marketplace 输入Maven Helper即可找到。

image
image

下载后,重启IDEA,这时点击pom.xml文件,会发现多了一栏【Dependency Analyzer】——

image
image

切换至【Dependency Analyzer】栏,在搜索框输入冲突包guava,即会出现,guava都被哪些包依赖了,当多个组件包都依赖了同一个包但又不同版本时,很容易久出现各种冲突。红色部分即是导致启动报异常的地方,可见,springfox-core已经依赖的是20.0包,但其他还依赖18版本的包,这里可以把报错提示的18.0版本的通过exclusion去除即可。

image
image

选中对应想去除的包,右击即可一键exclusion——

image
image

再切换至Text栏,即可发现已经自动增加了exclusions模块——

代码语言:javascript
复制
<dependency>
    <groupId>io.shardingsphere</groupId>
    <artifactId>sharding-jdbc-spring-namespace</artifactId>
    <version>3.1.0</version>
    <exclusions>
        <exclusion>
            <artifactId>guava</artifactId>
            <groupId>com.google.guava</groupId>
        </exclusion>
    </exclusions>
</dependency>
本文参与 腾讯云自媒体分享计划,分享自作者个人站点/博客。
原始发表:2022-01-15 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体分享计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
对象存储
对象存储(Cloud Object Storage,COS)是由腾讯云推出的无目录层次结构、无数据格式限制,可容纳海量数据且支持 HTTP/HTTPS 协议访问的分布式存储服务。腾讯云 COS 的存储桶空间无容量上限,无需分区管理,适用于 CDN 数据分发、数据万象处理或大数据计算与分析的数据湖等多种场景。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档