配置本地仓库到项目中报错问题分析
原因分析:导入依赖后,maven会先在本地仓库中寻找该依赖,如果找不到则会到中央仓库中去找,由于外网访问限制,所以可以配置阿里云的镜像仓库
IDEA项目配置本地maven
依次点击:file —> Setting —> Build,Execution,Deployment —> Build Tools —> Maven
(也可以在Settings那里直接搜索Maven)
将maven设置成本地下载配置好的maven
修改配置文件
1.setting.xml:
</mirrors>
<mirror>
<id>alimaven-central</id>
<mirrorOf>central</mirrorOf>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
</mirror>
<mirror>
<id>jboss-public-repository-group</id>
<mirrorOf>central</mirrorOf>
<name>JBoss Public Repository Group</name>
<url>http://repository.jboss.org/nexus/content/groups/public</url>
</mirror>
</mirrors>
<profile>
<id>jdk18</id>
<activation>
<jdk>1.8</jdk>
<activeByDefault>true</activeByDefault>
</activation>
<properties>
<maven.compiler.source>1.8</maven.compiler.source>
<maven.compiler.target>1.8</maven.compiler.target>
<maven.compiler.compilerVersion>1.8</maven.compiler.compilerVersion>
</properties>
</profile>
2.在项目的pom.xml文件中:
<!-- 远程阿里云仓库 -->
<repositories>
<repository>
<id>aliyun</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>aliyun-plugin</id>
<url>https://maven.aliyun.com/repository/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>false</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
执行
配置完成后,删除maven本地仓库的所有文件,在项目中执行maven clean install,这时会在阿里云仓库下载所需的依赖到本地仓库。