2

I moved a functionality of my Maven project because instead of a file.war, I wanted a .jar file to be able to run it from the command line. The problem is when I have been copying the dependencies of this project to the new one, my pom is the next one:

<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
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>MY_GROUP_ID</groupId>
<version>1.0.0.0</version>
<artifactId>MY_ARTIFACT_ID</artifactId>
<description>MY_DESCRIPTION</description>
<name>MY_NAME</name>
<packaging>jar</packaging>

<properties>
    <log4j.version>2.11.1</log4j.version>
    <maven.compiler.target>1.8</maven.compiler.target>
    <maven.compiler.source>1.8</maven.compiler.source>
</properties>

<dependencies>
    <dependency>
        <groupId>org.mongodb</groupId>
        <artifactId>mongo-java-driver</artifactId>
        <version>3.9.1</version>
    </dependency>
    <dependency>
        <groupId>org.junit.jupiter</groupId>
        <artifactId>junit-jupiter-api</artifactId>
        <version>5.3.2</version>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>com.jcraft</groupId>
        <artifactId>jsch</artifactId>
        <version>0.1.55</version>
    </dependency>
    <dependency>
        <groupId>org.projectlombok</groupId>
        <artifactId>lombok</artifactId>
        <version>1.18.4</version>
        <scope>provided</scope>
    </dependency>
    <dependency>
        <groupId>commons-cli</groupId>
        <artifactId>commons-cli</artifactId>
        <version>1.4</version>
    </dependency>
    <dependency>
        <groupId>com.google.code.gson</groupId>
        <artifactId>gson</artifactId>
        <version>2.8.5</version>
    </dependency>
    <dependency>
        <groupId>com.google.guava</groupId>
        <artifactId>guava</artifactId>
        <version>27.0.1-jre</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>${log4j.version}</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-slf4j-impl</artifactId>
        <version>${log4j.version}</version>
    </dependency>


</dependencies>


<build>
    <plugins>
        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-compiler-plugin</artifactId>
            <version>3.6.1</version>
            <configuration>
                <source>1.8</source>
                <target>1.8</target>
            </configuration>
        </plugin>
    </plugins>
</build>

The main problem that I get is that the methods log.error () and log.info () that I had written in code in the other application and that worked perfectly, in this new project do not work, when adding the @ Slf4j tag to my class, Example:

  @Slf4j
  @Data
  public class MY_CLASS {
  private String variable1;
  private String variable2;
  private String variable3;
  private String variable4;
  private String variable5;

The error that I get it's next one:

Logger cannot be resolved to a type.

org.slf4j cannot be resolved to a type.

org.slf4j.LoggerFactory cannot be resolved to a type.

I clean project, i reinstall project lombok, etc...

Thank's for help ^^

Community
  • 1
  • 1
aarauz
  • 21
  • 1
  • 3
  • Does this answer your question? [Building with Lombok's @Slf4j and Eclipse: Cannot find symbol log](https://stackoverflow.com/questions/16627751/building-with-lomboks-slf4j-and-eclipse-cannot-find-symbol-log) – AncientSwordRage May 13 '20 at 08:42

2 Answers2

1

For what I know, in eclipse if you have "cleaned and compiled" it with maven and the dependencies didn't load properly try right clicking and go to maven, then "Update Project", in the new window you should select everything related to that project and mark "Force update of Snapshot/Releases", this could maybe solve your problem.

TheYaINN
  • 114
  • 10
  • 1
    Hey TheYaINN thank's for read the post :) I did it too but nothing happends, it's like there are 2 versions installed but if i remove one of them and Update Project/Maven install still downloading 2 versions. `SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/aarauz/.m2/repository/org/apache/logging/log4j/log4j-slf4j-impl/2.2/log4j-slf4j-impl-2.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]` – aarauz Dec 07 '18 at 10:30
0

I had this problem, and I had to add the missing dependency:

<dependency>
   <groupId>org.slf4j</groupId>
   <artifactId>slf4j-api</artifactId>
</dependency>
Phong Phuong
  • 369
  • 4
  • 8