Maven dependency update on commandline
JavaEclipseMavenDependenciesJava Problem Overview
I have a maven project that was built on the commandline for eclipse and one of the dependencies is constantly changing. How do I update this dependency on the commandline as I have heard that it is a bad idea to mix m2e plugin and commandline. Furthermore, I tried running mvn eclipse:eclipse
on the command line and it messes up the project in eclipse removing the dependencies folder.
Java Solutions
Solution 1 - Java
mvn clean install -U
-U
means force update of dependencies.
Also, if you want to import the project into eclipse, I first run:
mvn eclipse:eclipse
then run
mvn eclipse:clean
Seems to work for me, but that's just my pennies worth.
Solution 2 - Java
If you just want to re-load/update dependencies (I assume, with constantly changing you mean either SNAPSHOTS or local dependencies you update yourself), you can use
mvn dependency:resolve
Solution 3 - Java
Simple run your project online i.e mvn clean install
. It fetches all the latest dependencies that you mention in your pom.xml and built the project
Solution 4 - Java
mvn clean install -U
also make sure if you have your dependencies behind a VPN, you are connected to that VPN
Solution 5 - Java
I recently stumbled upon an error in IntelliJ IDEA. Which arise, when I checkout in git an older branch which is uses older dependency versions in the pom.xml.
My codebase is getting littered with java: package com.foo.bar does not exist
and
java: cannot find symbol
symbol: class Baz
location: class com.foo.bar
error messages.
The solution is to reload the project in the maven tab.
I tried to automate that, but it seems that it is due to the fact, that IntelliJ is not noticing, that these files need to be indexed.
Hope that this helps someone. And if someone got to know how to update that over the console or as an pre-run task, please let me know.
Solution 6 - Java
mvn -Dschemaname=public liquibase:update