0
点赞
收藏
分享

微信扫一扫

maven 配置本地仓库、中央仓库、私库

 

1.准备条件

  找到maven的安装目录--》conf目录--》settings.xml文件,例如:D:\apache-maven-3.5.3\conf

2.仓库配置

  第一,本地仓库

  找到settings标签,紧挨着它就是被注释掉的localRepository标签,在这个位置配置<localRepository></localRepository>并设置仓库位置即可。例如:

<!-- 指定maven本地仓库位置 -->
<localRepository>D:\repository-maven</localRepository>

  第二,中央仓库

  找到mirrors标签,紧挨着它就是被注释掉的mirror标签,在这个位置配置<mirror></mirror>并设置仓库位置即可。例如:

<!-- 指定中央仓库 -->
<mirror>
<id>alimaven</id>
<name>aliyun maven</name>
<url>http://maven.aliyun.com/nexus/content/groups/public/</url>
<!-- <url>http://maven.aliyun.com/nexus/content/repositories/central/</url> -->
<mirrorOf>central</mirrorOf>
</mirror>

  第三,私库

  找到profiles标签,紧挨着它就是被注释掉的profile标签,在这个位置配置<profile></profile>并设置仓库位置。例如:

<!--私服仓库配置-->  
<profile>
<id>profile-nexus</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://192.168.57.182:8081/nexus/content/groups/public/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://192.168.57.182:8081/nexus/content/groups/public/</url>
<snapshots><enabled>true</enabled></snapshots>
<releases><enabled>true</enabled></releases>
</pluginRepository>
</pluginRepositories>
</profile>

  并且,需要在profiles标签体外添加activeProfiles标签,引用该私服

</profiles>
<!--私服仓库配置-->
<activeProfiles>
<activeProfile>profile-nexus</activeProfile>
<activeProfile>nexus</activeProfile>
</activeProfiles>

  jar包下载顺序:

  本地仓库--》nexus私服仓库--》线上的中央仓库   

写在最后

  哪位大佬如若发现文章存在纰漏之处或需要补充更多内容,欢迎留言!!!


举报

相关推荐

0 条评论