您的位置:首页 > 其它

maven探究四:在maven中配置nexus作为私服仓库

2017-04-19 16:02 405 查看
    让maven项目使用nexus作为远程仓库有两种方式,第一种是在项目的pom.xml中进行更改,让单个项目使用nexus仓库;另一种是通过修改maven的配置文件settings.xml进行更改,让所有项目都使用nexus仓库。第一种方式需要针对每个项目都进行配置,较为繁琐。故建议选择第二种配置方式,一次性到位。

进入maven安装目录的conf文件夹打开,修改settings.xml文件。

<profile>
<id>nexusprofile</id>
<repositories>
<repository>
<id>nexus</id>
<name>nexus repository</name>
<url>http://192.168.x.x:8181/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
</profile>
</profiles>
<activeProfiles>
<activeProfile>nexusprofile</activeProfile>
</activeProfiles>注意: <activeProfile>标签的目的是激活上面的profile配置功能,一定要加上。 而且标签中的内容一定要和profile当中的id保持一致。

配置成功后,maven工程在下载依赖的时候,会自动从nexus私服当中下载,如果nexus当中没有,则nexus会自动从maven中央仓库下载,并缓存在nexus当中。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: