• centos7搭建nexus maven私服(二)


     博客园bug,文章不能取消置顶。故重发。

    该篇是centos7搭建nexus maven私服(一)的后续篇。

    https://www.cnblogs.com/grey-wolf/p/6481166.html

    本文主要补充两个主题:

    1.手动更新索引

    2.通过maven客户端发布本地jar包到nexus

    先说第一个主题:

    由于maven中央仓库汇集了全世界绝大多数的组件,所以它的索引库非常庞大,在我们右击仓库update index时,经常是点击了之后无反应。

    这时候我们需要手动下载index文件,并上传到nexus的索引目录下。

    操作步骤如下:

    1.我们需要的文件如下:

    2.第一个文件的来源如下:

    http://download.csdn.net/detail/a3bbs/9552308

    http://search.maven.org/#search%7Cga%7C1%7Cg%3A%22org.apache.maven.indexer%22

    第二个文件和第三个文件来源:

    http://repo.maven.apache.org/maven2/.index/

    3、把这几个文件放在同一个文件路径下面,从cmd进入到这个路径,输入命令: 
    java -jar indexer-cli-5.1.1.jar -u nexus-maven-repository-index.gz -d indexer

    执行完之后,会生成indexer目录。

    4、停止nexus进程。在linux下执行./nexus stop

    5、将indexer下的所有内容都放到%nexus-home%sonatype-work exusindexercentral-ctx下面。 

    (我是在本地windows下执行,生成indexer后,上传到linux对应目录)

    4、重新启动nexus,进入管理界面,选择central->Browse Index,就看到更新的索引了。 

    第二个主题:

    1、在要发布到nexus的项目pom中,添加

    <distributionManagement>
            <repository>
                <id>releases</id><!--这个ID需要与你的release仓库的Repository ID一致-->
                <url>http://192.168.2.220:8081/nexus/content/repositories/releases/</url>
            </repository>
    
            <snapshotRepository>
                <id>snapshots</id><!--这个ID需要与你的snapshots仓库的Repository ID一致-->
                <url>http://192.168.2.220:8081/nexus/content/repositories/snapshots/</url>
            </snapshotRepository>
        </distributionManagement>

    上面的id与下图箭头标识处对应:

    2、在maven的配置文件settings.xml中,添加

    <!-- servers
    | This is a list of authentication profiles, keyed by the server-id used within the system.
    | Authentication profiles can be used whenever maven must make a connection to a remote server.
    |-->

    <servers>
            <server>
                <id>releases</id>
                <username>admin</username>
                <password>admin123</password><!--这个密码就是你设置的密码-->
            </server>
            <server>
                <id>snapshots</id>
                <username>admin</username>
                <password>admin123</password><!--这个密码就是你设置的密码-->
            </server>
        </servers>

    3、测试一下

    在idea中的maven projects中,点击deploy发布:

    可以看到日志显示:

    在nexus上查看:

    至此,两个主题就到此结束了。

    有问题可以留言回复。

  • 相关阅读:
    SQL Server ->> 生成代码把表字段从NULL改为NOT NULL
    Hadoop ->> MapReduce编程模型
    SQL Server ->> 建立linked server到Azure SQL Server
    SQL Server ->> 存储过程sp_rename重命名数据对象
    SQL Server ->> CLR存储过程枚举目录文件并返回结果集
    SQL Server ->> 查看SQL Server备份历史
    SQL Server ->> 生成时间类型的Partition Function和Partition Scheme代码
    SQL Server ->> CLR编程问题汇总
    Hadoop ->> Name node/Data node和Job tracker/Task tracker的区别
    Hadoop ->> Hadoop是什么?
  • 原文地址:https://www.cnblogs.com/grey-wolf/p/10172204.html
Copyright © 2020-2023  润新知