环境: redhat 6.5、nexus版本: 2.12.0
1.下载安装包 https://sonatype-download.global.ssl.fastly.net/nexus/oss/nexus-2.12.0-01-bundle.tar.gz
我的计划安装目录: /home/hadoop/tools/nexus
$ tar zxvf nexus-2.12.0-01-bundle.tar.gz -C /home/hadoop/tools/
2.如有需要可以更改nexus的默认端口
vi /home/hadoop/tools/nexus-2.12.0-01/conf/nexus.properties 参考如下:
application-port=8601
3.启动Nexus:
$ /home/hadoop/tools/nexus-2.12.0-01/bin/nexus start
然后打开web URL: http://IP:8601/nexus 即可看到
选择右上角login,用户名/密码 admin/admin123
4.选择左列菜单[Repositories]可以查看repository的列表,关于Nexus的库:
Public Repositories group http://localhost:8681/nexus/content/groups/public/
3rd party hosted
Apache Snapshots proxy
Central proxy
Central M1 shadow virtual
Releases hosted
Snapshots hosted
以上repository的类型
hosted:本地仓库,通常我们会部署自己的构件到这一类型的仓库。比如公司的第二方库。
proxy:代理仓库,它们被用来代理远程的公共仓库,如maven中央仓库。
group:仓库组,用来合并多个hosted/proxy仓库。
virtual:虚拟库
关于Public Repositories,我们使用Nexus通常用这个库即可,选中[Public Repositories],点击下方[Configuration]即可看到Orderd Group Repositories
5.(可选)修改Maven的setting.xml可以使得maven下载jar包通过nexus从internet下载
vi setting.xml
<profiles> <profile> <id>nexusProfile</id> <repositories> <repository> <id>nexus</id> <name>Nexus Repository</name> <url>http://localhost:8681/nexus/content/groups/public/</url> <releases><enabled>true</enabled></releases> <snapshots><enabled>true</enabled></snapshots> </repository> </repositories> </profile> </profiles> <activeProfiles> <activeProfile>nexusProfile</activeProfile> </activeProfiles>
6.添加3rd party jar
示例:遇到报错[ERROR] Failed to execute goal on project saiku-web: Could not resolve dependencies for project org.saikuanalytics:saiku-
web:jar:3.8-RC5: Failure to find org.apache.pdfbox:pdfbox-app:jar:2.0.0 in http://repo.meteorite.bi/content/repositories/alabs-release-
local/ was cached in the local repository, resolution will not be reattempted until the update interval of Analytical Labs Repo has elapsed or
updates are forced -> [Help 1]
我们可以通过向nexus添加pdfbox-app-2.0.0.jar包,根据以上信息可以确定:
<groupId>org.apache.pdfbox</groupId>
<artifactId>pdfbox-app</artifactId>
<version>2.0.0</version>
Step1 单击 3rd party,选中 Artifact Upload。GAV Definition 选中 GAV Parameters,
单击下方[Select Artifacts(s) to Upload]然后选择jar包,并补充上方信息,参考如下:
Step2 单击左下方 Add Artifact,加到Artifacts表中
Step3 最后选择最下方 Upload Artifacts(s)即可添加到3rd party repository中进行使用