Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

maven compilation - error log4j

Tags:

i'm building java application and suddenly i found problem with compilation:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.3.2:compile (default-compile) on project sonda: Compilation failure: Compilation failure: [ERROR] ..../service/UserService.java:[7,23] package org.apache.log4j does not exist 

But i was building this application before and everything was ok. Additionally, when i run this application under Eclipse using tomcat, it's running well.

In pom i have:

<dependency>         <groupId>org.slf4j</groupId>         <artifactId>slf4j-api</artifactId>         <version>${org.slf4j-version}</version>     </dependency>     <dependency>         <groupId>org.slf4j</groupId>         <artifactId>jcl-over-slf4j</artifactId>         <version>${org.slf4j-version}</version>         <scope>runtime</scope>     </dependency>     <dependency>         <groupId>org.slf4j</groupId>         <artifactId>slf4j-log4j12</artifactId>         <version>${org.slf4j-version}</version>         <scope>runtime</scope>     </dependency>     <dependency>         <groupId>log4j</groupId>         <artifactId>log4j</artifactId>         <version>1.2.15</version>         <exclusions>             <exclusion>                 <groupId>javax.mail</groupId>                 <artifactId>mail</artifactId>             </exclusion>             <exclusion>                 <groupId>javax.jms</groupId>                 <artifactId>jms</artifactId>             </exclusion>             <exclusion>                 <groupId>com.sun.jdmk</groupId>                 <artifactId>jmxtools</artifactId>             </exclusion>             <exclusion>                 <groupId>com.sun.jmx</groupId>                 <artifactId>jmxri</artifactId>             </exclusion>         </exclusions>         <scope>runtime</scope>     </dependency> 

Can you help me ?

like image 787
Ilkar Avatar asked Dec 29 '11 12:12

Ilkar


People also ask

Does Maven use Log4j?

As you can see in this answer, maven supports SLF4J logging. If you just add the Log4j to SLF4j adapter to the plugin. By adding this dependency, log4j will redirect to SLF4j and SLF4j redirects to the maven logging.

What is the latest version of Log4j?

logging. Log4j 2.18. 0 is the latest release of Log4j.

What is Log4j API?

The Log4j 2 API provides the interface that applications should code to and provides the adapter components required for implementers to create a logging implementation.


1 Answers

Change the scope of the log4j dependency to compile or remove it.

like image 92
Arnaud Gourlay Avatar answered Oct 09 '22 09:10

Arnaud Gourlay