您的位置:首页 > 其它

nexus的私服的搭建(maven私有仓库)

2017-06-19 15:34 507 查看
环境:本机window7 nexus2.11 腾讯云centos6.7服务器

————————–有趣的分割线————–

1、Linux下,进入/usr/local目录,并创建一个nexus目录(用来安装nexus)

mkdir nexus


2、把在window7下载的的nexus软件包通过winscp软件上传到centos下刚刚创建的nexus目录

3、解压 nexus

tar -xvf nexus-2.11.3-01-bundle.tar.gz


4、进入bin目录运行nexus

./nexus start


此时会报 : If you insist running as root, then set theenvironment variable RUN_AS_USER=root before running this script. 的警告信息。大概的意思是:如果你想使用root用户,那么在运行开始脚本之前应该设置环境变量”RUN_AS_USER=root”。

解决方案:设置centos下的环境变量

参考另一篇博客:http://blog.csdn.net/happy_bigqiang/article/details/51000582

5、启动nexus 在浏览器中输入 localhost:端口号/nexus,默认端口号是8081;这里的localhost是你服务器的地址;

6、点击页面右上角的Log in,使用Nexus 内置账户admin;密码admin123登陆;

7、登录成功说明安装成功;

————————–任性的昏割线————–

将项目发布到私服,需求是企业中多个团队协作开发通常会将一些公用的组件、开发模块等发布到私服供其它团队或模块开发人员使用。

1、需要在客户端即部署dao工程的电脑上配置 maven环境,并修改 settings.xml 文件,配置连接私服的用户和密码 ,此用户名和密码用于私服校验,因为私服需要知道上传都 的账号和密码 是否和私服中的账号和密码 一致。

<server>
<id>releases</id>
<username>admin</username>
<password>admin123</password>
</server>
<server>
<id>snapshots</id>
<username>admin</username>
<password>admin123</password>
</server>


releases 连接发布版本项目仓库

snapshots 连接测试版本项目仓库

2、配置项目pom.xml ,配置私服仓库的地址,本公司的自己的jar包会上传到私服的宿主仓库

<distributionManagement>
<repository>
<id>releases</id>
<url>http://localhost:8081/nexus/content/repositories/releases/</url>
</repository>
<snapshotRepository>
<id>snapshots</id>
<url>http://localhost:8081/nexus/content/repositories/snapshots/</url>
</snapshotRepository>
</distributionManagement>


注意:pom.xml这里id 和 settings.xml 配置 id 对应!

这里的localhost是你服务器的地址;

3、测试将项目dao工程打成jar包发布到私服:

首先启动nexus

其次,对dao工程执行deploy命令 ,即在选中maven项目,右键run as,maven build…,goals中输入tomcat7:deploy;注意这里用的是maven的tomcat7的插件;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: