How to force update dependencies Commandline eclipse Intelli

This post explains how to force snapshots and release dependencies in a Maven project using both the command line and Eclipse.

During development, Maven performs installations by downloading all snapshots and releasing dependencies for the first time. However, build failures may occur due to incomplete downloads of some dependencies, often caused by network latency issues.

Maven retrieves repositories from remote sources such as Maven Central or Nexus. In my Java application, the build failed because spring-core loaded partially and wasn’t 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 to force 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.

 mvn dependency:purge-local-repository

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

mvn dependency:resolve

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 and is

One way, with a project setting as described in a sequence of steps

  • Open the project in eclipse
  • Right-click on the project
  • Select the Maven option - select the 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

maven force update dependencies eclipse IDE

Update Project window popups as seen Check the below option

  • Force Update of Snapshots/Releases
maven check snapshot release update dependencies eclipse

How to update maven dependencies in Intelli IDEA

Open the project in Intelli IDEA

  • Open File -> settings, window popup
  • Check maven option
  • select Always update snapshots checked maven check snapshot release update dependencies Intelli IDEA

Conclusion

Learned maven force update to re-download dependencies with examples.