ubuntu10.x ,maven下nexus的搭建,jar包上传等注意事项(转载补漏加工总结贴)

nexus是用来搭建本地jar包服务器到,具体就不多说了。
主要是参考里下面到帖子。在此感谢作者。

[url=http://blog.csdn.net/mydeman/archive/2010/09/25/5905424.aspx]持续集成之路——搭建Maven私服[/url]

[url=http://blog.csdn.net/cuker919/archive/2010/10/05/5922007.aspx]Maven仓库管理-Nexus(转帖后加强版)[/url]

[size=x-large][b]nexus的安装[/b][/size]

[b]1.nexus的下载地址[/b]

[url]http://nexus.sonatype.org/downloads/[/url]
我下载的是 nexus-oss-webapp-1.8.0-bundle.tar.gz

解压后得到2个文件:nexus-oss-webapp-1.8.0 和 sonatype-work
前者包含了nexus的运行环境和应用程序,后者包含了你自己的配置和数据。

[b]2.启动nexus[/b]

在上面提到,nexus的运行环境在nexus-oss-webapp-1.8.0目录,下面就进入这个目录启动:

# cd nexus-oss-webapp-1.8.0/bin/jsw/linux-x86-32/


在这个目录下包含了一个文件夹和三个文件:lib、nexus、platform和wrapper,其中nexus就是启动命令。

执行
# ./nexus

得到nexus到提示命令 如 start,stop,status,restart 等。

输入
# ./nexus start


终端出现

Starting Nexus OSS...
Started Nexus OSS

说明nexus启动成功

注意:jsw文件夹下有很多针对不同操作系统到文件夹,选中适合自己操作系统的文件夹。
也可以把start,stop做成脚本 放在桌面上,避免不停的cd
附件为start和stop的脚本,请打开脚本修改自己本机上nexus的路径。

[b]3.打开nexus[/b]

在浏览器中访问:[url]http://localhost:8081/nexus[/url]

出现

[img]http://dl.iteye.com/upload/attachment/345965/bb18c92a-c5fe-34d4-b7fb-0f84101f0db7.png[/img]
点击右上角的login in
输入帐号:admin
输入密码:admin123
登录成功

[b][size=x-large]配置nexus[/size][/b]


由于在新搭建的nexus环境中只是一个空的仓库,所以第一步就是要和远程的Maven中心仓库进行同步。

[img]http://dl.iteye.com/upload/attachment/345967/d9546c31-1846-34b9-bf6d-53666a95c2c3.jpeg[/img]

[img]http://dl.iteye.com/upload/attachment/345969/429f1d54-e2a6-30a3-9ea9-110c626345d7.png[/img]

如果在Reindex之后,并没有同步到远程的仓库,可以检查每个仓库的设置。下面是Maven Central的设置:

[img]http://dl.iteye.com/upload/attachment/345971/d12fcfb7-212e-3518-8a19-37bb709d3e9a.png[/img]


开打maven目录 -> conf -> settings.xml

找到localRepository
上面到注释信息写道:Default: ~/.m2/repository
我们可以添加
<localRepository>${M3_HOME}/repository</localRepository>


${M3_HOME}是maven到安装路径,新建个repository文件夹用来装入本地的jar包

顺手把以前默认的repository删除。
#cd ~
#rm -rf .m2


依次在settings.xml文件里输入

<!-- nexus帐号和密码 -->

<server>
<id>nexus-releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>nexus-snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>
</servers>

...

<!-- 引用naxus仓库组 -->
<profile>
<id>dev</id>
<repositories>
<repository>
<id>nexus</id>
<url>http://127.0.0.1:8081/nexus/content/groups/public/</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<pluginRepositories>
<pluginRepository>
<id>nexus</id>
<url>http://127.0.0.1:8081/nexus/content/groups/public</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</pluginRepository>
</pluginRepositories>
</profile>
..

<!-- nexus -->
<activeProfiles>
<activeProfile>dev</activeProfile>

</activeProfiles>


注意:根据标签位置准确输入

[b][size=x-large] 上传jar到本地仓库[/size][/b]


[img]http://dl.iteye.com/upload/attachment/345998/8c3716cf-51fc-30b1-812a-0e5778f9dc6f.png[/img]


选中3rd party 点击Artifact Upload标签
点击 select artifact(s) 按钮 选择要上传到jar包 然后再add artiffact -> uplaod artiffact 即可。

编辑pom.xml的时候可能找不到在nexus的jar包

[img]http://dl.iteye.com/upload/attachment/346004/408e892f-aa2b-346a-b483-c4254b34d428.png[/img]

在nexus里查询本地上传的jar包
复制xml代码到pom.xml文件保存即可。

编辑好pom.xml后保存
完毕后在${M3_HOME}/repository 文件里可看到导入的jar包。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值