settings.xml中配置本地仓库地址,C:\Users\lv\.m2\repository
为你本地仓库路径,修改成你的就行
<?xml version="1.0" encoding="UTF-8"?>
<settings>
<localRepository>C:\Users\lv\.m2\repository</localRepository>
<mirrors>
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<mirrorOf>central</mirrorOf>
</mirror>
<mirror>
<id>jitpack</id>
<mirrorOf>jitpack</mirrorOf>
<name>jitpack库</name>
<url>https://jitpack.io</url>
</mirror>
</mirrors>
</settings>
android build.gradle中使用mavelLocal()引用
allprojects {
repositories {
mavenLocal()
maven { url 'http://maven.aliyun.com/nexus/content/groups/public/' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/jcenter' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/google' }
maven { url 'http://maven.aliyun.com/nexus/content/repositories/gradle-plugin' }
mavenCentral()
maven { url "https://jitpack.io" }
}
}
mavenLocal的解释
/**
* Adds a repository which looks in the local Maven cache for dependencies. The name of the repository is
* {@value org.gradle.api.artifacts.ArtifactRepositoryContainer#DEFAULT_MAVEN_LOCAL_REPO_NAME}.
*
* <p>Examples:</p>
* <pre class='autoTested'>
* repositories {
* mavenLocal()
* }
* </pre>
* <p>
* The location for the repository is determined as follows (in order of precedence):
* </p>
* <ol>
* <li>The value of system property 'maven.repo.local' if set;</li>
* <li>The value of element <localRepository> of <code>~/.m2/settings.xml</code> if this file exists and element is set;</li>
* <li>The value of element <localRepository> of <code>$M2_HOME/conf/settings.xml</code> (where <code>$M2_HOME</code> is the value of the environment variable with that name) if this file exists and element is set;</li>
* <li>The path <code>~/.m2/repository</code>.</li>
* </ol>
*
* @return the added resolver
*/
MavenArtifactRepository mavenLocal();