Java modules - module not found: org.slf4j

Viewed 45

I am studying java modules and faced with this error:

I tried to put this "module in my declaration"

module mymodule {
  requires org.slf4j;
} 

-- mvn clean package

Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.10.1:compile module not found: org.slf4j

My pom.xml:

 <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-core</artifactId>
    </dependency>

    <dependency>
      <groupId>org.apache.logging.log4j</groupId>
      <artifactId>log4j-slf4j-impl</artifactId>
    </dependency>

I found that the "Automatic module name is":

module mymodule {
  requires org.apache.logging.log4j.slf4j;
}

But now I have this error:

(package org.slf4j is declared in the unnamed module, but module org.slf4j does not read it)

How can I solve this? Whys this is happening?

0 Answers
Related