I'm running mvn install, getting below error:
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:2.5.1:compile error: package org.apache.log4j does not exist
In my project hierarchy I have log4j-1.2.15.jar added as a Referenced Libraries..not sure what I'm missing.
Part of POM file with log4j dependency (should I change the version to just say 1.2...or possible remove the scope below?):
<dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-api</artifactId> <version>1.2.15</version> <scope>compile</scope> </dependency> <dependency> <groupId>org.apache.logging.log4j</groupId> <artifactId>log4j-core</artifactId> <version>1.2.15</version> </dependency>
[ERROR] Failed to execute goal on project project1: Could not resolve dependencies for project com.title.proj:project1:jar:0.1-SNAPSHOT: The following artifacts could not be resolved: org.apache.logging.log4j:log4j-api:jar:1.2.15, org.apache.logging.log4j:log4j-core:jar:1.2.15: Could not find artifact org.apache.logging.log4j:log4j-api:jar:1.2.15 in central (https://repo.maven.apache.org/maven2) -> [Help 1 - raptor496 2017-05-29 22:39
log4jjar. In your
.m2directory, if you find dependencies of
org.apache.logging, delete them and do a
mvn clean installharshavmb 2017-05-30 07:50
For log4j I only use this libraries:
<dependency> <groupId>log4j</groupId> <artifactId>log4j</artifactId> <version>1.2.17</version> </dependency>
At first, it can be related with some your customizations of the environment or with dependencies in your *.pom file (Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin (default-compile) on project: Fatal error compiling: tools.jar not found). You need to check default installed "jre" to a jdk. Also ensure maven instalation and , namely paths:
When I execute the command:
echo $JAVA_HOME I will have
/usr/lib/jvm/java-9-oracle and appropriate path for maven
For eclipse users this directly resolved this problem. There is no need to re-install anything with maven installed in eclipse oxygen centos 6. Vogella tutorial below says to resolve the dependency by adding the .jar via downloaded index at startup. As identified above answer 1.2.17 is around the same solution that worked for me (1.2.15) You must launch eclipse in a terminal with JAVA_HOME set as mentioned above. Eclipse will handle the rest.
Identifies how to download the dependency list. Once you setup your project you open the pom gui and select Dependencies. You search for the above mentioned library select and add it. During initial build, the dependent .jar is downloaded and configured dynamically via the pom.xml state injection, this is why no manual deleting or re-install is necessary.
It is still not managed- To manage the dependency, i.e. add it to the pom, you select the item you just added and click manage and follow the prompts to add it the Dependency Management list. This is an automatic pom addition from the gui - `
<dependency> <groupId>org.eclipse.ecf</groupId> <artifactId>org.apache.log4j</artifactId> <version>1.2.15.v201012070815</version> </dependency>`
When the Dependency Management list is populated your library will display a (managed:version) tag in orange.
Start smiling, right click pom, run as maven build, the errors should be gone.