用maven管理项目时,如果某人加入了maven中心库无法下载到的依赖包,则其他人同步代码后整个项目会报错,我们可以配置一个自己的maven库来解决这个问题。http://maven.apache.org/repository-management.html推荐了几个可用于配置maven库的软件,比如Apache Archiva,Artifactory。本文将选择nexus来配置一个maven库。
操作系统为64位Centos 6.3
1.从http://www.sonatype.org/nexus/go下载nexus-2.3.0-04.zip或者nexus-2.3.0-04-bundle.tar.gz
nexus-2.3.0-04.zip解压之后放入Tomcat等web容器中即可,下面介绍nexus-2.3.0-04-bundle.tar.gz配置。
2.下面命令最好不要用root帐号操作,因为nexus不推荐用root帐号启动,而目录拥有者和启动帐号不一致会有其他问题产生
3.解压下载的文件到安装目录,比如:/usr/local,tar -zxf nexus-2.3.0-04-bundle.tar.gz
4.进入解压目录,chmod -R a+x bin
5.启动nexus,bin/jsw/linux-x86-64/nexus start
6.启动nexus的帐号对sonatype-work(和nexus-2.3.0-04目录同级)目录要有读写权限
7.在浏览器输入http://ip:8081/nexus,在页面右上角有登录连接,默认账户是admin,密码admin123(注意防火墙是否允许访问8081接口)
8.点击Repositories将会看到如下界面,其中红色框的三个库是我们配置自己maven的主要原因
9.首先上传一个第三方的包(淘宝sdk),按下图提示填入后upload即可
10.然后我们把自己的项目安装到这个库中,首先需要配置settings.xml
<server>
<id>inexus</id>
<username>admin</username>
<password>admin123</password>
</server>
然后在项目的pom.xml文件中加入如下xml片段
<distributionManagement>
<repository>
<id>inexus</id>
<name>Release</name>
<url>http://192.168.202.129:8081/nexus/content/repositories/releases/</url> </repository>
<snapshotRepository>
<id>inexus</id>
<name>Snapshots</name>
<url>http://192.168.202.129:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>
然后使用mvn:deploy命令即可将项目安装到maven库中
11.从自己的maven库获取依赖包,配置settings.xml文件,其中profile片段可以放到项目的pom.xml中
<profile>
<id>nexus</id>
<repositories>
<repository>
<id>inexus</id>
<url>http://192.168.202.129:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots> </repository>
</repositories>
</profile>
<activeProfiles>
<activeProfile>nexus</activeProfile>
</activeProfiles>
12.当有web的项目时, 如果maven-war-plugin过低时发布会报错
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-war-plugin</artifactId>
<version>2.3</version>
</plugin>
- 大小: 54.3 KB
- 大小: 59.2 KB
- 大小: 47.6 KB
分享到:
相关推荐
nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库nexus 搭建 maven仓库
打造自己的maven内部库 Nexus是Sonatype推出的强大Maven仓库管理器产品。有以下优点: 代理远程仓库。配置Nexus代理中央仓库,其它任何公开的Maven仓库,将你组织内部的Maven配置指向Nexus,这样所有构件都将从Nexus...
maven nexus 配置,简要介绍如何配置nexus。。。。。。
java maven仓库 搭建Nexus
建立Maven私服 – Nexus下载、安装、配置、使用 建立Maven私服 – Nexus下载、安装、配置、使用
go语言写的一个工具,用于批量上传本地仓库的jar到nexus私库。目前只有exe没有生成linux脚本。文件夹中有使用说明。 .\mvnDeployTool.exe -r C:\\Users\\yyc\\.m2\\repository\\org\\apache\\maven -s D:\devEnv\...
maven3.8.3+nexus3.34.zip
maven仓库清理命令
超全面搭建Maven仓库:Maven环境变量配置,Maven仓库创建(本地资源库,中央资源库),Eclipse内配置Maven环境
Maven deploy到 nexus(csdn)————程序
Maven Nexus 私服搭建 从零开始,资源下载、安装指导、开发配置说明
该文档是关于配置maven私服nexus,对maven学习者有很大的帮助
maven入门,maven环境的搭建以及maven配置到eclipse以及pom.xml文件配置等
Windows 下Nexus搭建Maven私服 Windows 下Nexus搭建Maven私服
如何进行Linux安装配置maven以及搭建nexus服务器.docx
史上最全的maven setting配置,包括私服nexus,maven.aliyun.com,repo.maven.apache.org
Maven 安装与配置(csdn)————程序
Maven仓库的搭建,包教会,详细文档,注意事项都有提示
详细的maven库jar包,该仓库搜索的后台使用了Nexus,Nexus是目前为止最为强大的Maven仓库管理器,而且,它是开源的。如果你组织内部在大量使用Maven,那么就会需要假设自己的Maven仓库,Nexus是很好的选择,你可以...
Maven私服搭建必备,完整的Maven私服和本地仓库搭建步骤