geoserver-manager依赖中低版本的slf4j依赖版本冲突

在pom文件中dependencies部分的最上面引入版本1.8-SNAPSHOT的 geoserver-manager 依赖后,运行报错

  • Exception in thread “main” java.lang.AbstractMethodError
SLF4J: The requested version 1.7.16 by your slf4j binding is not compatible with [1.5.5, 1.5.6, 1.5.7, 1.5.8, 1.5.9, 1.5.10, 1.5.11]
SLF4J: See http://www.slf4j.org/codes.html#version_mismatch for further details.
Exception in thread "main" java.lang.AbstractMethodError: 
Receiver class ch.qos.logback.classic.Logger does not define or inherit an implementation of the resolved method abstract log
(Lorg/slf4j/Marker;Ljava/lang/String;ILjava/lang/String;Ljava/lang/Throwable;)V of interface org.slf4j.spi.LocationAwareLogger.

Reason: 所引入的依赖中包含低版本的日志依赖,需移除
geoserver-manager所依赖的包
Solution: 排除依赖:slf4j-api & jcl-over-slf4j 1.5.11 version

<dependency>
    <groupId>it.geosolutions</groupId>
    <artifactId>geoserver-manager</artifactId>
    <version>${geoserver-manager.version}</version>
    <scope>compile</scope>
    <exclusions>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>slf4j-api</artifactId>
        </exclusion>
        <exclusion>
            <groupId>org.slf4j</groupId>
            <artifactId>jcl-over-slf4j</artifactId>
        </exclusion>
    </exclusions>
</dependency>
  • java.lang.NoSuchMethodError: org.slf4j.spi.LocationAwareLogger.log

Reason: slf4j.spi的jar版本过低


maven依赖原则(两条)

  1. 路径最近者优先

    相同jar不同版本,根据依赖的路径长短来决定引入哪个依赖

  2. 第一声明者优先

    在依赖路径长度相等的前提下,在POM中依赖声明的顺序决定了谁会被解析使用,顺序最前的那个依赖优胜

    子pom内声明的优先于父pom中的依赖


Tips: 使用 IDEA中 Maven Helper 插件,Dependency Analyzer

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值