Is there some index or cache that needs to be refreshed or deleted when I copy over the Maven repository from another computer?
I would like to copy the local Maven repository from my laptop for use on another computer that is effectively offline. After copying the files from ~/.m2/repository it does not work as expected. When I execute mvn package -o
I get an error that it cannot find one of the artifacts from the new repository:
[ERROR] Failed to execute goal on project [...]: Could not resolve dependencies for project [...]:
Cannot access central (https://repo.maven.apache.org/maven2) in offline mode and the artifact com.oracle:ojdbc6:jar:11.2.0.3.0 has not been downloaded from it before.
But I do have the artifact in the folder at ~/.m2/repository/com/oracle/ojdbc6/11.2.0.3.0
that was copied in from the other computer. (This particular one is not public; it is stored on our company Nexus server which cannot be reached from the target system.)
Custom Local Repository in settings. That config file is located in the Maven installation directory in a folder called conf, with the name settings. xml.
m2 folder is the default folder used by maven to store its: settings. xml file which specifies properties, like the central repository to download your dependencies, the location of the so-called localRepository. by default, the localRepository in which maven stores all the dependencies your project might need to run.
Maven uses the "update policy" in the settings.xml file to decide whether to download the artifact or to use the one in the local repository if available.
If you don't want Maven to update your dependencies, you should configure <updatePolicy>never</updatePolicy>
. You also need to use the same repository <id>
s in both locations.
So if you are only using Maven's Central Repository, your repository
configuration would look something like this:
<repository>
<id>central</id>
<name>Maven Central</name>
<url>https://repo1.maven.org/maven2</url>
<releases>
<enabled>true</enabled>
<updatePolicy>never</updatePolicy>
<checksumPolicy>warn</checksumPolicy>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With