Can't determine why maven is downloading a jar file - maven

I am having an issue with log4j-api. I have specified log4j-api:2.8.1 in my pom but when running a mvn clean install command, mvn keeps insisting that I need log4j-api:2.1. If i delete the log4j-api:2.1 directory from my .m2/repository and do the mvn clean install command, it will say it is downloading the 2.1 version.
Here's the weird thing: If I do a mvn dependency:tree there is no mention of version 2.1, only 2.8.1.
Anybody understand why mvn dependency:tree would say my project is NOT dependent on version 2.1 but then downloads the 2.1 version when I run mvn clean install?
Some other versions we are using in case somebody knows that something could be causing this:
Spring Boot 1.2.1
Spring Framework 4.1.6
Elastic Java APIs 5.6.4

Get the dependency tree in verbose mode
mvn dependency:tree -Dverbose
From maven docs
More specifically, in verbose mode the dependency tree shows dependencies that were omitted for: being a duplicate of another; conflicting with another's version and/or scope; and introducing a cycle into the dependency tree.

Related

Primefaces maven how to build snapshot version?

Do I need to change the version in pom.xml? For example,
11.0.0.snapshot20220708
Is there command line options for building a snapshot version?
Yes I do this everyday with 12.0.0-SNAPSHOT in the pom.xml run this maven command.
mvn clean install but it must be -SNAPSHOT

mvn clean install pulls in old snapshot version that don't exist

I am trying to compile my code and with the latest version. I see that the old SNAPSHOT version is being picked up as well when I check the .war file. I ran the dependency:tree and checked if it had anything to do with it but nothing came up which said so.
Is there a way I can change the pom.xml to ensure this doesn't happen.?
Run the build with -U and you get the newest SNAPSHOT versions.

Maven tool of Java, how to using mvn uninstall package?

Java, mvn tool, how to using mvn uninstall package? Have some plugin, tool, shell script and command method?
If you want to uninstall/remove any artifact downloaded by maven just go to your ~/.m2/repository directory, where all installed artifacts are stored and delete that one which you want to get rid of.
All you have to do is remove the dependency from your pom.xml, maven should take care of the rest.
I really struggled with this because I had an upstream dependency that included the dependency I was trying to remove, so even mvn dependency:purge-local-repository didn't help - in that case, it might be worth trying to configure dependency exclusions (also in the pom.xml file).

Base command line for builds in Maven

I am using apache maven version 3.5.0 in Eclipse. I have problem with this error - "org.apache.maven.plugins:maven-eclipse-plugin:2.10:eclipse". I guess it makes by wrong command in Preferences->Anypoint Studio->Maven->Base command line for builds. Now, I have command - "mvn eclipse:clean eclipse:eclipse -Dwtpversion=2.0".
The maven-eclipse-plugin is deprecated and should not be used. Actually, it can destroy your project.
Newer Eclipse versions (like Mars, Neon, Oxygen) have m2e included, which does all the Maven-Eclipse magic for you.

Difference between mvn and mvn3 command

I have latest version of maven installed which is 3.0.4. A test at command line with mvn -version results in confirming this.
For all my maven commands I am using mvn but on several occasion on the internet I have seen people using mvn3 instead what is the difference between the two commands and why I am unable to use mvn3?
Seems like (according to How do I install Maven 3?), default installation of maven 3 on Ubuntu uses mvn3 symlink to mvn.
I can't find mvn3 command neither in 3.0.3 nor in 3.0.4. I believe mvn3 is only used to emphasize that maven 3 should be used as opposed to maven 2 (still popular). These two versions are significantly different so it's worth to make sure newer is used.

Resources