在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: 所引入的依赖中包含低版本的日志依赖,需移除
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依赖原则(两条)
-
路径最近者优先
相同jar不同版本,根据依赖的路径长短来决定引入哪个依赖
-
第一声明者优先
在依赖路径长度相等的前提下,在POM中依赖声明的顺序决定了谁会被解析使用,顺序最前的那个依赖优胜
子pom内声明的优先于父pom中的依赖
Tips: 使用 IDEA中 Maven Helper 插件,Dependency Analyzer