How to get maven to download poms for offline use

My problem with maven is that if the maven repository is not responding, it cannot be created. It seems that every “mvn package” package brings some pores that will not change because they have the same version.

How can I tell maven that please do not browse them from the server and instead download them continuously to the offline repository?

Thanks!

+7
maven-2
source share
2 answers

You can run maven with the -o flag:

  -o,--offline Work offline 

This will force Maven to never look for dependencies in remote repositories. On the other hand, your build will fail if dependencies are not found in the local repository.

+11
source share

You can configure the repository to check for updates only occasionally or never setting the updatePolicy element in the repository declaration. From the settings documentation :

The update download frequency can be "always", "daily" (default), "interval: XXX" (in minutes) or "never" (only if it does not exist locally).

Adding the following to your POM or settings will cause the central repository to load only if the artifact does not exist locally:

 <repositories> <repository> <id>central</id> <releases> <updatePolicy>never</updatePolicy> </releases> </repository> </repositories> 

If the repository in question is an internal remote repository, you need to make sure that maven-metadata.xml is configured correctly on the remote control repository or Maven will try to download it every time. The easiest way to do this is to use a repository manager that will automatically manage metadata

+11
source share

All Articles