安装NEXUS私有仓库

来源:互联网 发布:知乎官方首页 编辑:程序博客网 时间:2024/06/05 17:54

环境:

  centos6.3 minimal

  jdk-7u40-linux-i586.tar.gz

  apache-maven-3.1.1-bin.tar.gz

  nexus-2.7.0-05-bundle.zip

 

 

下载:

 #yum install -y wget unzip

 #cd /opt

 //jdk-7u40-linux-i586.tar.gz使用浏览器下载后复制到opt目录

 #wget http://download.sonatype.com/nexus/oss/nexus-2.7.0-05-bundle.zip

 #wget http://mirrors.hust.edu.cn/apache/maven/maven-3/3.1.1/binaries/apache-maven-3.1.1-bin.tar.gz

 

 安装:

 #tar  zxvf  jdk-7u40-linux-i586.tar.gz

 #tar zxvf  apache-maven-3.1.1-bin.tar.gz

 #unzip nexus-2.7.0-05-bundle.zip

 

 #mv jdk1.7.0_40  /usr/local

 #mv apache-maven-3.1.1  /usr/local

 #mv nexus-2.7.0-05  /usr/local

 #mv sonatype-work  /usr/local

 

 #useradd nexus   //新建一个用户

 #chown nexus -R  /usr/local/nexus-2.7.0-05

 #chown nexus -R  /usr/local/sonatype-work

 #vim /usr/local/nexus-2.7.0-05/bin/nexus

   修改 RUN_AS_USER=nexus

 

设置环境变量:

 #vim /etc/profile

  在原有export PATH之前添加以下内容:

   export JAVA_HOME="/usr/local/jdk1.7.0_40"

   export CLASSPATH="$JAVA_HOME/lib/dt.jar:$JAVA_HOME/tools.jar"

   PATH="$JAVA_HOME/bin:$PATH"

   export M2_HOME="/usr/local/apache-maven-3.1.1"

   export M2="$M2_HOME/bin"

   PATH="$M2:$PATH"

 

设置开机启动项:

  #echo "/usr/local/nexus-2.7.0-05/bin/nexus start"  >>  /etc/rc.local

 

启动:

  #/usr/local/nexus-2.7.0-05/bin/nexus help   //查看命令项

  #/usr/local/nexus-2.7.0-05/bin/nexus start

 //nexus默认启动端口是8081

 

访问:

  先关闭iptables或者开启8081端口

  比如服务器ip是192.168.1.80

  使用浏览器:http://192.168.1.80:8081/nexus

 

 默认用户:admin

        密码:admin123

 

 设置:

  使用admin登陆系统后,点击左边栏Repositories,设置中央仓库central自动下载indexes,Download Remote Indexes设置为TRUE,如下图

 

  设置仓库组,点击Public Repositories,在Configuration下会出现二个列表框,左边的是实际在仓库组的,右边的是当前可得到的未在仓库组的,如下图

 

  Eclipse使用设置:

  当前使用eclipse juno版本,先需要安装e2clipse

  打开eclipse -> 菜单栏help -> Install New Software ->  Add -> Name: m2e  Location:http://wiki.eclipse.org/M2E_updatesite_and_gittags

  安装好后,eclipse -> 菜单栏Window -> Preferences -> 左边会有MAVEN选项

  编辑用户setting.xml,添加mirror

<mirror>    <id>nexus</id>    <mirrorOf>*</mirrorOf>    <name>public repos</name>    <url>http://192.168.1.80:8081/nexus/content/groups/public/</url></mirror><profile>      <id>nexus</id>      <repositories>        <repository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </repository>      </repositories>     <pluginRepositories>        <pluginRepository>          <id>central</id>          <url>http://central</url>          <releases><enabled>true</enabled></releases>          <snapshots><enabled>true</enabled></snapshots>        </pluginRepository>      </pluginRepositories></profile><activeProfiles>    <activeProfile>nexus</activeProfile></activeProfiles>

添加到相应节点下。

 

 如果用户不能搜索index,有二种方式可以使用:

 第一种:菜单栏Window -> Show view -> Maven repositories

可以右键Rebuild Index。

如果这种方法还是不行,那么可以使用第二种方法:

清除e2clipse缓存,删除.m2\repository\.cache\m2e\下面所有的子文件夹,重启eclipse一般就能解决。

 

0 0
原创粉丝点击