-2

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.

enter image description here

santino87
  • 53
  • 6
  • ..and where is your code? – Giorgi Tsiklauri Sep 21 '20 at 13:22
  • i guess, it's not related to code cause it's working fine through eclipse. – santino87 Sep 21 '20 at 13:29
  • better post the [minimal reproducible example](https://stackoverflow.com/help/minimal-reproducible-example) than guess what is needed and what not, otherwise, we can't help you. How we may understand what's going wrong? now you've uploaded the image, and seems like build is successful. What is the other problem cannot be deduced from this post only. Please update accordingly. – Giorgi Tsiklauri Sep 21 '20 at 13:37

1 Answers1

0

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.

SinisaT90
  • 92
  • 2
  • how can i understand which version of slf4j is decided by maven ? i can list by mvn dependency:tree but not able to read it. – santino87 Sep 21 '20 at 13:57
  • As I see I think on image you post jcl104-over-slf4j could make you a problem.. You need to add exclusion for that dependency ` org.slf4j jcl104-over-slf4j ` – SinisaT90 Sep 21 '20 at 14:33