Sonatype Nexus OSS的安装及使用

https://www.sonatype.com/nexus-repository-oss

定位:

一个免费的Maven 私服的仓库

下载、安装、启动

$:tar xzf nexus-3.14.0-04-unix.tar.gz
$:cd nexus-3.14.0-04/bin
bin $:./nexus start

此时,可以使用http://localhost:8081进行访问,管理账号为admin/admin123,服务器上预提供了一些仓库,可以直接使用

屏幕快照 2018-11-04 下午10.01.34.png

加入私服的方法:

在pom.xml中加入:

<repositories>
    <repository>
        <id>maven-public</id>
        <name>maven-public</name>
        <url>http://localhost:8081/repository/maven-public/</url>
        <snapshots>
            <enabled>true</enabled>
        </snapshots>
    </repository>
</repositories>

发布项目的方法:

  1. 在setting.xml中:
<servers>
    <server>
        <id>nexus-releases</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
    <server>
        <id>nexus-snapshots</id>
        <username>admin</username>
        <password>admin123</password>
    </server>
</servers>
  1. 在"待布署的项目"的pom.xml中:
    <distributionManagement>
        <repository>
            <id>nexus-releases</id>
            <name>maven-releases</name>
            <url>http://localhost:8081/repository/maven-releases/</url>
        </repository>
        <snapshotRepository>
            <id>nexus-snapshots</id>
            <name>maven-snapshots</name>
            <url>http://localhost:8081/repository/maven-snapshots/</url>
        </snapshotRepository>
    </distributionManagement>
  1. 发布:
mvn deploy

为什么要设置group类型的仓库

屏幕快照 2018-11-04 下午10.51.03.png
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容