英文:
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
命令来检查依赖树,但没有得到有意义的结果。
英文:
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.
<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>
In addition, i tried to check dependency tree by using mvn dependency:tree but it didn't come to meaningful.
答案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.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论