首页 > 技术文章 > IDEA找不到maven仓库无法下载依赖解决办法

beichenroot 2019-09-16 15:13 原文

1.确认Maven安装正常,在cmd窗口输入mvn -version 可以获得版本号;

2. 确认maven安装包下/conf/setting.xml配置文件正确

本地仓库位置:

<localRepository>D:\03sources\mvn-repository</localRepository>

远程中央仓库:

<mirrors>
	<mirror>  
		<id>nexus-aliyun</id>  
		<mirrorOf>central</mirrorOf>    
		<name>Nexus aliyun</name>  
		<url>http://maven.aliyun.com/nexus/content/groups/public</url> 
	</mirror>
</mirrors>

3. 确认idea设置正常,file - settings - maven

  此处代表idea可以找到的仓库位置,若右侧URL下方为空则说明idea未识别到有效仓库,此时无法下载依赖;

 

4. 临时解决办法,在项目的pom文件中添加如下信息,即可找到阿里中央仓库,自动下载依赖

    <repositories>
        <repository>
            <id>alimaven</id>
            <name>Maven Aliyun Mirror</name>
            <url>http://maven.aliyun.com/nexus/content/repositories/central/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <snapshots>
                <enabled>false</enabled>
            </snapshots>
        </repository>
    </repositories>

 

问题:仍未解决为何idea不能正常加载maven配置文件中仓库的问题。

 

推荐阅读