NoSuchMethod org.slf4j.spi.LocationAwareLogger error

huangapple go评论187阅读模式
英文:

NoSuchMethod org.slf4j.spi.LocationAwareLogger error

问题

我在通过命令行输入 mvn clean test 后,在我的代码中遇到了 NoSuchMethod org.slf4j.spi.LocationAwareLogger 错误。

可能与 Maven 依赖项有关,但我无法确定在 pom.xml 中应该将其安排在哪里。

<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-api</artifactId>
    <version>1.7.30</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-log4j12</artifactId>
    <version>1.7.25</version>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-jdk14</artifactId>
    <version>1.7.25</version>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>org.slf4j</groupId>
    <artifactId>slf4j-nop</artifactId>
    <version>1.7.25</version>
    <scope>test</scope>
</dependency>

此外,我尝试使用 mvn dependency:tree 命令来检查依赖树,但没有得到有意义的结果。

NoSuchMethod org.slf4j.spi.LocationAwareLogger error

英文:

I'm facing with NoSuchMethod org.slf4j.spi.LocationAwareLogger erro in my code after typing mvn clean test command through cmd.

Probably it's related to maven dependency but i couldn't figure out where i should exactly arrange in pom xml.

 &lt;dependency&gt;
    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
    &lt;artifactId&gt;slf4j-api&lt;/artifactId&gt;
    &lt;version&gt;1.7.30&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
    &lt;artifactId&gt;slf4j-log4j12&lt;/artifactId&gt;
    &lt;version&gt;1.7.25&lt;/version&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
    &lt;artifactId&gt;slf4j-jdk14&lt;/artifactId&gt;
    &lt;version&gt;1.7.25&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;
&lt;dependency&gt;
    &lt;groupId&gt;org.slf4j&lt;/groupId&gt;
    &lt;artifactId&gt;slf4j-nop&lt;/artifactId&gt;
    &lt;version&gt;1.7.25&lt;/version&gt;
    &lt;scope&gt;test&lt;/scope&gt;
&lt;/dependency&gt;

In addition, i tried to check dependency tree by using mvn dependency:tree but it didn't come to meaningful.

NoSuchMethod org.slf4j.spi.LocationAwareLogger error

答案1

得分: 0

使用mvn dependency:tree命令查看Maven决定为您提供的slf4j版本。如果它选择了错误的版本,您可以使用dependency management部分指定所需的版本。同时,您需要在pom.xml中添加排除以排除您不使用的依赖。

另外,如果您在使用Eclipse集成开发环境,还有另一种解决方法:使用SHIFT + CTRL + T快捷键打开"SLF4JLocationAwareLog",您将能够找到相关的库以及潜在的冲突。切换到pom.xml的dependency tree视图,以了解需要添加的排除项。

英文:

Use mvn dependency:tree to see which version of slf4j maven decides to give you. If it has picked the wrong version, you could use a dependency management section to specify which version you want. And you need to add exclusion to pom to dependacy you dont use.

In addition, another way to fix if using Eclipse IDE, use SHIFT + CTRL + T to open following type "SLF4JLocationAwareLog"
You should be able to find related library and so a potential conflict.
Switch to the dependency tree view of the pom.xml to know the exclusion to add.

huangapple
  • 本文由 发表于 2020年9月21日 21:18:12
  • 转载请务必保留本文链接:https://go.coder-hub.com/63993111.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定