This post describes how to do the command line and Eclipse to force snapshot and release dependencies in a Maven project.
During development, maven do installation by downloading all snapshot and releasing dependencies for the first time. Build fails the reason of not downloading some of its dependencies. The reason might be not downloading the dependencies completely because of network latency issues.
Maven downloads the repositories from remote repositories like maven central or nexus. My java application build failed as spring-core loaded partially and was not downloaded completely.
Build errors for mavenapp; org.apache.maven.lifecycle.LifecycleExecutionException: Failed to execute goal on project mavenapp: Could not resolve dependencies for project com :mavenapp:war:0.0.1-SNAPSHOT: The following artifacts could not be resolved: org.springframework:spring-core:jar:5.0.1.RELEASE
How to force update dependencies of a maven project command line?
maven command has an option
-U or `–update snapshots option to update the snapshot dependencies.
mvn clean install -U mvn clean install --update-snapshots
There is another way with the
maven dependency plugin goal.
purge-local-repository clean local repository.
Once the local repository is clean, install dependencies using the below command
mvn clean install
The above two commands can be run using a single command.
mvn dependency:purge-local-repository clean install
This updates all snapshots and releases dependencies.
The final way is using dependency:resolve goal in maven
This updates all dependencies of a maven project.
if you want to update a single dependency
mvn dependency:get -Dartifact=group_id:artifact_id:version
How to force update release and snapshot dependencies in eclipse?
It is easy to update all dependencies of the eclipse project in many ways is
One way, with project setting as described in a sequence of steps
- Open the project in eclipse
- Right-click on the project
- Select Maven option - select Update project option
- you can see the below screenshot for more information
The same above steps can be replaced with short cut command Alt + F5
Update Project window popups as seen Check below option
- Force Update of Snapshots/Releases
How to update maven dependencies in Intelli IDEA
Open the project in
- Open File -> settings, window popup
- Check maven option
Always update snapshotschecked
Learned maven force update to re-download dependencies with examples.