Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder" IntelliJ issue

I am getting this error in my IntelliJ program: SLF4J: Failed to load class "org.slf4j.impl.StaticLoggerBinder". SLF4J: Defaulting to no-operation (NOP) logger implementation SLF4J: See http://www.slf4j.org/codes.html#StaticLoggerBinder for further details. Feature: Shout

From research, it looks like I am missing JAR files, updating the class path etc. Some answers say to add dependencies in the Maven POM, so I've done this, hit "build" and reran the feature file with the same results. Some answers also say to add the jar file but I am really unfamiliar with Java IDEs and not a developer. I've googled how to add a jar file and most answers tell me to go to Project structure in IntelliJ. In artifacts part of Project Structure, I hit "+" and I see an option to Create jar from modules but this popup is really confusing. I don't understand what I'm supposed to do with it. I've also downloaded the SLF4J jar files but I don't know how to get them in IntellJ. Create JAR from Modules doesn't seem to have a link to the desktop to import anything. Creating jar from empty results in another screen that doesn't seem to have any link to the desktop. Other results say to add a jar file from the + sign under modules and this also doesn't seem to give any option. I'm also not sure how big a problem this is because running my feature file results in the incorrect output and may regardless of this issue.

Here's my POM, then:

     xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">

<modelVersion>4.0.0</modelVersion>



<groupId>cucumber-school</groupId>

<artifactId>shouty</artifactId>

<version>0.0.1</version>

<packaging>jar</packaging>

<name>Shouty</name>



<properties>
    <java.version>1.8</java.version>
    <junit.version>4.12</junit.version>

    <cucumber.version>2.3.1</cucumber.version>

    <cucumber.pro.version>2.0.4</cucumber.pro.version>

    <maven.compiler.version>3.3</maven.compiler.version>

</properties>



<dependencies>

    <dependency>

        <groupId>io.cucumber</groupId>

        <artifactId>cucumber-java</artifactId>

        <version>${cucumber.version}</version>

        <scope>test</scope>

    </dependency>



    <dependency>

        <groupId>io.cucumber</groupId>

        <artifactId>cucumber-junit</artifactId>

        <version>${cucumber.version}</version>

        <scope>test</scope>

    </dependency>



    <dependency>

        <groupId>io.cucumber</groupId>

        <artifactId>pro-plugin</artifactId>

        <version>${cucumber.pro.version}</version>

        <scope>test</scope>

    </dependency>



    <dependency>

        <groupId>junit</groupId>

        <artifactId>junit</artifactId>

        <version>${junit.version}</version>

        <scope>test</scope>

    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-log4j12</artifactId>
        <version>1.7.5</version>
    </dependency>
    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.7.21</version>
    </dependency>

</dependencies>
like image 262
Julie Pixie Avatar asked Dec 05 '22 12:12

Julie Pixie


1 Answers

Adding this here in the hope that it will help someone else somewhere along the line. I am using IntelliJ on a Mac. Initially, I was getting the "Failed to load class org.slf4j.impl.StaticLoggerBinder message" so I added the following dependencies:

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-api</artifactId>
        <version>1.8.0-beta2</version>
    </dependency>

    <dependency>
        <groupId>org.slf4j</groupId>
        <artifactId>slf4j-simple</artifactId>
        <version>1.8.0-beta2</version>
        <scope>test</scope>
    </dependency>

Note that the versions should be changed to the desired one for each. After this I began getting the "No SLF4J providers were found" error message. I had to go to File -> Project Structure -> Modules -> Dependencies tab -> Select the two dependencies -> Make sure their scope is "Compile" not "Test" -> Click "Apply" -> Click "OK".enter image description here

like image 56
Patience Mpofu Avatar answered Dec 11 '22 12:12

Patience Mpofu