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 ?
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.
logging. Log4j 2.18. 0 is the latest release of Log4j.
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.
Change the scope of the log4j dependency to compile or remove it.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With