Maven_linux下 maven安装及nexus私服搭建

一、安装前的准备

      下载 jdk     http://www.oracle.com/technetwork/java/javase/downloads/jdk-6u26-download-400750.html   

                      jdk-6u26-linux-x64.bin

      下载maven http://mirrors.geoexpat.com/apache//maven/binaries/  

                      apache-maven-3.0.3-bin.tar.gz

      下载nexus  http://nexus.sonatype.org/downloads/  

                      nexus-oss-webapp-1.9.1.1-bundle.tar.gz   

      http://www.sonatype.org/downloads/all/

二、安装jdk

  使用root用户

      添加执行权限   chmod  a+x   jdk-6u26-linux-x64.bin          

      安装              ./ jdk-6u26-linux-x64.bin        按Enter 完成安装

三、maven安装及配置

      1、创建需要操作 maven 的用户组以及用户( 如果用 root 用户安装不用创建)  

           1.    #groupadd  mavenuser                       // 创建用户组   

           2.    #useradd -g  mavenuser  mavenuser    // 创建用户并指定用户组   

           3.    #passwd  mavenuser                          // 为用户分配密码   

      2、解压安装

           1.   #cd /data  

           2.   #mkdir maven  

           3.    #chown -R  mavenuser  : mavenuser  /data/maven  

           4.    #chmod  755  /data/maven  

           5.    #su -l  xinhua   

           6.   #tar -zvxf  apache-maven-3.0.3-bin.tar.gz

       3、配置

           在用户主目录 查看是否有   .m2 目录

           如果没有建立  mkdir  .m2 

           在.m2 目录建立  settings.xml   内容为

复制代码
<? xml version="1.0" encoding="UTF-8" ?>
< settings xmlns ="http://maven.apache.org/SETTINGS/1.0.0"
xmlns:xsi
="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation
="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd" >

<!-- 指定jar包存放路径 -->
< localRepository > /data/maven/apache-maven-3.0.3/repo/ </ localRepository >

< pluginGroups > </ pluginGroups >

<!-- 设置代理服务器 -->
< proxies >
< proxy >
< id > my-proxy </ id >
< active > true </ active >
< protocol > http </ protocol >
< host > ipaddress </ host >
< port > port </ port >
</ proxy >
</ proxies >

<!-- 设置私服server -->
< servers >
< server >
< id > nexus </ id >
< username > admin </ username >
< password > admin </ password >
</ server >
</ servers >

<!-- 配置私服作为镜像,只允许maven使用私服 -->
< mirrors >
< mirror >
< id > nexus </ id >
< mirrorOf > * </ mirrorOf >
< url > http://localhost:8081/nexus/content/groups/public </ url >
</ mirror >
</ mirrors >
< profiles >
< 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 >
</ profiles >

< activeProfiles >
< activeProfile > nexus </ activeProfile >
</ activeProfiles >

</ settings >
复制代码

四、nexus安装

            解压   tar -zxvf  nexus-oss-webapp-1.9.1.1-bundle.tar.gz  

五、编写启动脚本

     可以在任意文件夹下创建启动脚本

            启动脚本:

            vi   mavenStart.sh

            将下面脚本添加进去

            #!/bin/bash

            export LANG='zh.GB18030'

            M2_HOME=/data/maven/apache-maven-3.0.3

            export M2_HOME

            JAVA_HOME=/data/jdk1.6.0_26/bin

            PATH=$JAVA_HOME:$PATH:$HOME/bin:$M2_HOME/bin

            export PATH

            /data/maven/nexus-oss-webapp-1.9.1.1/bin/jsw/linux-x86-64/nexus start

运行脚本时命令为:

~/maven$ sudo -s
~/maven# ./mavenStart.sh
bash: ./mavenStart.sh: Permission denied
root@aaa~/maven# chmod +x mavenStart.sh
root@aaa:~/maven# ./mavenStart.sh
Starting Nexus OSS...
Started Nexus OSS.

这样Nexus就启动了,然活输入http://127.0.0.1:8081/nexus是不是就出来登录页面了呢。

            停止脚本:

            vi   mavenStop.sh

            将下面脚本添加进去

            #!/bin/bash

            /data/maven/nexus-oss-webapp-1.9.1.1/bin/jsw/linux-x86-64/nexus stop6

六、nexus使用及配置

    1、运行

                服务端启动mavenStart.sh 脚本

                在浏览器中输入: http://ipaddress:8081/nexus 

                就可以看到 nexus  的主页,点击右上角 Log in 

                默认用户名和密码是: admin/admin123 

          2、配置

                点击左侧 Repositories 

                将所有Type 是  proxy 的 configuration配置选项中的 Download Remote Index  配置改为 True

                如果需要代理将配置最下面的Override Http Proxy Setting  勾上并填写代理服务器地址和端口,最后保存设置  

                然后在列表中分别右键点击 ReIndex 

          3、添加自己的jar到nexus

               选中 3rd party , Artifact Upload 标签

               GAV Definition   选择GAV Parameters

               填写 Group      Artifact         version           packaging

               然后选择jar包 上传提交即可。


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值