Maven nexus安装、配置跟使用

Maven nexus安装、配置和使用
    这块详情可以参考《Maven实战》-许晓斌(PDF链接:http://pan.baidu.com/s/1pJvCyuB 密码:6asf),第九章讲的很详细。这里只记录快速配置和简单说明。

一、安装Nexus(Linux下)

    Nexus是典型的Java Web应用,它有两种安装包,一种是包含Jetty容器的Bundle包,另一种是不包含Web容器的war包。      

    1. 下载 

        官网下载很麻烦,这里有下好的Bundle包(链接:http://pan.baidu.com/s/1c0hfJY4 密码:vw83

    2. 安装

         # tar xzvf nexus-oss-webapp-1.8.0-bundle.tar.gz

    3. 启动

        进入cd  /usr/nexus/nexus-2.11.2-06/bin

        ./nexus start

      (输入./nexus 回车可以查看其他命令Usage: ./nexus { console | start | stop | restart | status | dump } ) 

       nexus默认监听的端口是8081。那么我们就可以在浏览器中访问:http://host:8081/nexus   


二、配置Nexus

    默认的用户名和密码:admin/admin123(一般登陆以后要修改密码),端口如果有冲突可以在/usr/nexus/nexus-2.11.2-06/conf的nexus.properties里面修改,下面是一些必要的配置(把索引打开)

 Maven nexus安装、配置跟使用


二、本地使用

    Maven安装可以参考http://blog.csdn.net/Jerome_s/article/details/38424435

    电脑安装好maven后,在${MAVEN_HOME}→conf→settings.xml配置、和修改存放jar包的路径(要在{MAVEN_HOME}新建repository文件夹,并将配置文件settings拷贝到repository文件下,方便Maven升级)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
<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">
   
  <localRepository>${MAVEN_HOME}/repository</localRepository>
 
  <profiles>
  
    <profile>
       <id>dev</id>
          <repositories>
             <repository>
                 <id>nexus</id>
                 <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>
                 <releases>
                    <enabled>true</enabled>
                 </releases>
                 <snapshots>
                    <enabled>true</enabled>
                 </snapshots>
              </repository>
            </repositories>           
            <pluginRepositories>
                <pluginRepository>
                    <id>nexus</id>
                    <url>http://xx.xx.xx.xx:8181/nexus/content/groups/public/</url>
                    <releases>
                        <enabled>true</enabled>
                    </releases>
                    <snapshots>
                        <enabled>true</enabled>
                    </snapshots>
                </pluginRepository>
            </pluginRepositories>
        </profile>
  </profiles>
  
  <activeProfiles>
        <activeProfile>dev</activeProfile>
    </activeProfiles
</settings>

记得Eclipse要修改指定的maven安装目录和指定的settings.xml位置

Maven nexus安装、配置跟使用


Maven nexus安装、配置跟使用

四、上传仓库没有的Jar包到nexus

Maven nexus安装、配置跟使用

使用 (拷贝到项目pom.xml使用)
Maven nexus安装、配置跟使用

效果
Maven nexus安装、配置跟使用


PS:别的同事初次部署可以将repository文件夹考到他电脑对应目录下,并在Eclipse指定版本和setting即可。