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 download all snapshot and release dependencies for the first time. Build fails with a reason of not downloading some of its dependencies. The reason might be not downloaded the dependencies completely because of network latency issues.
Maven download the repositories from remote repositories like maven central or nexus. My java application build failed as spring-core loaded partially and 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 a option
--update-snapshots option to update the snapshot dependencies.
mvn clean install -U mvn clean install --update-snapshots
There is another way with
maven depedency plugin goal
purge-local-repository clean local repository.
Once local repository is clean , install dependencies using below command
mvn clean install
The above two commands can be run using single command
mvn dependency:purge-local-repository clean install
This updates all snapshot and release dependencies.
Final way is using dependency:resolve goal in maven
This updates all dependencies of a maven project.
if you want to update single dependency
mvn dependency:get -Dartifact=group_id:artifact_id:version
How to force update release and snapshot dependencies in eclipse?
It is very easy to update all dependencies of eclipse project in many way is
One way, with project setting as described in sequence of steps
- Open project in eclipse
- Right click on project
- Select Maven option - select Update project option
- you can see the below screenshot for more information
The same above steps can be replace with short cut command Alt + F5
Update Project window poups 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