一、准备工作

     系统:LINUX
          JDK:已安装(未安装详见jdk安装教程:http://www.cnblogs.com/muzi1994/p/5818099.html)
          Maven:已安装(未安装详见maven安装教程:http://www.cnblogs.com/muzi1994/p/6030181.html)
          Nexus:http://www.sonatype.org/nexus/go
                     所有版本下载地址:http://www.sonatype.org/nexus/archived/
          Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维护和外部仓库的访问。

二、安装Nexus

  1.解压nexus文件

1
[root@centos6 var]# tar -zvxf nexus-2.12.0-01-bundle.tar.gz

  

      注:解压后有两个文件夹:

nexus-2.12.0-01: 是nexus的核心文件

sonatype-work :maven下载jar存放地址

  2.启动Nexus

1
2
3
4
5
6
[root@centos6 nexus-2.12.0-01]# ./bin/nexus start
 
- ****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
If you insist running as root, then set the environment variable RUN_AS_USER=root before running this script.

  默认情况下,不建议以root用户运行Nexus,可以修改bin/nexus中的配置跳过警告(修改RUN_AS_USER=root)

1
[root@centos6 nexus-2.12.0-01]# vi bin/nexus

  

重新启动Nexus

1
2
3
4
5
6
7
[root@centos6 nexus-2.12.0-01]# ./bin/nexus start
 
- ****************************************
WARNING - NOT RECOMMENDED TO RUN AS ROOT
****************************************
Starting Nexus OSS...
Started Nexus OSS.

  注:Nexus默认端口8081,如果想修改端口。修改/conf/nexus.properties文件

访问网址:http://192.168.1.11:8081/nexus/#welcome

点击右上角的 Log In 按钮即可登陆了。默认登录账号/密码为: admin/admin123 ,登陆成功后的界面

  点击Repositories,将列表中所有Type为proxy 的项目的 Configuration 中的 Download Remote Indexes 设置为True

将Releases仓库的Deployment Policy设置为 Allow ReDeploy

      当然我们也避免不了会使用到一些第三方的 jar ,而这些jar包也不存在于互联网上的maven中央仓库中,这时我们可以手工添加jar 到我们的私服中。
      添加第三方 jar 如下:
      

填写完必选字段,点击Upload Artifact(s)按钮即可。

  3.配置本地项目引用私服

   自动发布构件到远程仓库,在工程pom.xml中添加

1
2
3
4
5
6
7
8
9
10
<distributionManagement>
    <repository>
        <id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致-->
        <url>http://192.168.1.11:8081/nexus/content/repositories/releases</url>
    </repository>
    <snapshotRepository>
        <id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->
        <url>http://192.168.1.11:8081/nexus/content/repositories/snapshots</url>
    </snapshotRepository>
</distributionManagement>

  修改本地$MAVEN_HOME\conf目录下的settings.xml配置文件,添加如下配置

1
2
3
4
5
6
7
8
9
10
11
12
<servers>
    <server>
        <id>releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>snapshots</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
</servers>

  在本地工程目录下执行:

1
mvn deploy

  所部署的包就自动上传到了nexus安装目录下的

  4.配置Maven从Nexus下载构件

    在POM中配置Nexus私服,这样的配置只对当前的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
<!--指定Nexus的构件仓库-->
<repositories>
    <repository>
        <id>public</id>
        <name>Team Maven Repository</name>
        <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>
 
<!--指定Nexus的插件仓库-->
<pluginRepositories>
    <pluginRepository>
        <id>public</id>
        <name>Team Maven Repository</name>
        <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>
        <releases>
            <enabled>true</enabled>
        </releases>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </pluginRepository>
</pluginRepositories>

  在settings.xml中配置profile元素,这样就能让本机所有的Maven项目都使用自己的Maven私服。

1
2
3
4
5
6
7
8
9
10
11
12
13
<properties>
        <repository>
            <id>public</id>
            <name>Team Maven Repository</name>
            <url>http://192.168.1.11:8081/nexus/content/groups/public/</url>
            <releases>
                <enabled>true</enabled>
            </releases>
            <layout>default</layout>
            <snapshots>
                <enabled>true</enabled>
            </snapshots>
        </repository><br></properties>

Linux使用nexus搭建maven私服的更多相关文章

  1. Linux 使用nexus搭建maven私服

    系统:LINUX           JDK:已安装           Maven:已安装           Nexus Nexus是一个强大的Maven仓库管理器,它极大地简化了自己内部仓库的维 ...

  2. Maven-004-使用 Nexus 搭建 maven 私服

    从去年至今,自己一直在学习自动化测试工具,想利用自动化工具尽可能的将重复的.关键的.耗时耗力的工作实现自动化,减轻日常测试工作,提升测试效率.在学习的过程中,将 maven 作为了项目开发管理工具,进 ...

  3. Maven使用笔记(五)Sonatype Nexus 搭建Maven 私服

    1. 为什么使用Nexus 如果没有私服,我们所需的所有构件都需要通过maven的中央仓库和第三方的Maven仓库下载到本地, 而一个团队中的所有人都重复的从maven仓库下载构件无疑加大了仓库的负载 ...

  4. Maven——使用Nexus搭建Maven私服

    原文:http://www.cnblogs.com/xdp-gacl/p/4068967.html Maven学习总结(九)--使用Nexus搭建Maven私服 一.搭建nexus私服的目的 为什么要 ...

  5. (转)Maven学习总结(九)——使用Nexus搭建Maven私服

    孤傲苍狼只为成功找方法,不为失败找借口! Maven学习总结(九)——使用Nexus搭建Maven私服 一.搭建nexus私服的目的 为什么要搭建nexus私服,原因很简单,有些公司都不提供外网给项目 ...

  6. Maven学习二:使用Nexus搭建Maven私服及相关配置

    处于安全等原因的考虑,一些企业内部网络是不允许访问外部网络的,但是项目内部搭建的项目又是Maven架构,这样就需要企业在内部网络中搭建自己的Maven仓库服务,再者一些大型企业或者内部模块化组件化划分 ...

  7. 使用Nexus搭建Maven私服问题总结

    #业务场景 最近项目要交付给客户了,之前项目开发和测试一直都是使用公司内部的一套环境,项目交付后客户购置了大量服务器,也要将整套测试环境迁移至客户的服务器上,后续的需求变更以及新需求的开发都会在客户服 ...

  8. nexus搭建maven私服及私服jar包上传和下载

    nexus搭建maven私服及私服jar包上传和下载 标签: nexus管理maven库snapshot 2017-06-28 13:02 844人阅读 评论(0) 收藏 举报 分类: Maven(1 ...

  9. nexus 搭建 maven 私服

    nexus 搭建 maven 私服 本机环境 Win 8 JDK 7 Maven 3.2 Nexus 2.11 版本选择 http://www.sonatype.org/nexus/archivedn ...

随机推荐

  1. Confluence 6 为空白空间编辑默认主页

    希望编辑默认(空白)空间内容模板: 在屏幕的右上角单击 控制台按钮 ,然后选择 General Configuration 链接. 在左侧的面板中选择 全局模板和蓝图(Global Templates ...

  2. Confluence 6 用户目录图例 - Confluence 内部目录

    上面的图:Confluence 使用内部目录为用户管理. https://www.cwiki.us/display/CONFLUENCEWIKI/Diagrams+of+Possible+Config ...

  3. js原生回到顶部,并平滑过渡---- 记录

    window.scrollTo({ top: 0, behavior: 'smooth', });

  4. OrCAD Capture CIS 16.6 快速地编辑Part的引脚名称

    操作系统:Windows 10 x64 工具1:OrCAD Capture CIS 16.6-S062 (v16-6-112FF) 工具2:Excel 参考1:http://www.360doc.co ...

  5. jenkins 回滚发布

    #jenkins拉取文件路径 workspace=/data/wos/testtemp #备份路径 backspace=/data/wos/back #不能提Git的文件 config=/data/w ...

  6. Python 9*9口诀

    #!/usr/bin/env python # _*_ coding:utf-8 _*_ # Author:Liuyoushui # Time = 2017/7/18 10:33 print ('\n ...

  7. Aws云服务EMR使用

    Aws云服务EMR使用 创建表结构 创建abc库下的abc_user_i表字段s3://abc-server/abc-emr/shell/ABC_USER_HIVE.q: EXTERNAL 指定为外部 ...

  8. exception: java.net.ConnectException: Connection refused; For more details see: http://wiki.apache.org/hadoop/ConnectionRefused

    1.虽然,不是大错,还说要贴一下,由于我运行run-example streaming.NetworkWordCount localhost 9999的测试案例,出现的错误,第一感觉就是Spark没有 ...

  9. kafka 备忘

    创建topic/usr/local/kafka/bin/kafka-topics.sh --create --zookeeper 127.0.0.1:2181 --partitions 3 --rep ...

  10. [转] 2016 JavaScript 发展现状大调查

    有人认为JavaScript是最好的语言,有人认为它一团糟.可按照C++之父的话来讲: 世界上只有两种编程语言:一种是天天被人喷的,另一种是没人用的. 不论你喜欢承认与否,JavaScript已经一天 ...