- N +

如何发布jar包到Maven私有仓库?

如何发布jar包到Maven私有仓库?原标题:如何发布jar包到Maven私有仓库?

导读:

了解如何使用Nexus3搭建Maven私有仓库之后,我们通常开发的JAR包,如何发布到Maven私有仓库呢?查看Maven版本:[root@client ~]# mvn --v...

文章目录 [+]

了解如何使用Nexus3搭建Maven私有仓库之后,我们通常开发的jar包,如何发布到Maven私有仓库呢?



查看Maven版本:









[root@client ~]# mvn --versionApache Maven 3.5.2 (138edd61fd100ec658bfa2d307c43b76940a5d7d; 2017-10-18T15:58:13+08:00)Maven home: /usr/share/apache-mavenjava version: 1.8.0_222, vendor: oracle CorporationJava home: /usr/lib/jvm/java-1.8.0-openjdk-1.8.0.222.b10-1.el7_7.x86_64/jreDefault locale: en_US, platform encoding: UTF-8OS name: "linux", version: "3.10.0-1062.1.1.el7.x86_64", arch: "amd64", family: "unix"
找到Maven安装路径:












[root@demon ~]# rpm -ql apache-maven/etc/bash_completion.d/maven/etc/m2.conf/etc/maven/etc/maven/logging/etc/maven/logging/simplelogger.properties/etc/maven/settings.xml/etc/maven/toolchains.xml/etc/profile.d/apache-maven.csh/etc/profile.d/apache-maven.sh/usr/bin/mvn......

打开文件编辑:


vim /etc/maven/settings.xml

修改本地maven库添加认证:


































  <!-- 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     | Specifies the authentication information to use when connecting to a particular server, identified by     | a unique name within the system (referred to by the 'id' attribute below).     |     | NOTE: You should either specify username/password OR privateKey/passphrase, since these pairings are     |       used together.     |    -->    <server>      <id>maven-releases</id>      <username>admin</username>      <password>xxxxxx</password>    </server>
   <server>      <id>maven-snapshots</id>      <username>admin</username>      <password>xxxxxx</password>    </server>
   <!-- Another sample, using keys to authenticate.    <server>      <id>siteServer</id>      <privateKey>/path/to/private/key</privateKey>      <passphrase>optional; leave empty if not used.</passphrase>    </server>    -->  </servers>

pom.xml添加远程仓库:












        <distributionManagement>                <repository>                        <id>maven-releases</id>                        <url>http://nexus.xxx.com/repository/maven-releases/</url>                </repository>
               <snapshotRepository>                        <id>maven-snapshots</id>                        <url>http://nexus.xxx.com/repository/maven-snapshots/</url>                </snapshotRepository>        </distributionManagement>

命令端上传jar包、使用maven命令上传jar包:


mvn deploy:deploy-file -DgroupId=域名.组织名 -DartifactId=包名 -Dversion=版本号 -Dpackaging=jar -Dfile=D:\fastdfs_client_v1.24.jar ID -Durl=http://X.X.X.X:8081/repository/xxx/ -DrepositoryId=创建库时的指定


本文标题:如何发布jar包到Maven私有仓库?
本文链接:http://kyjszj.com/htzq/409.html
作者授权:除特别说明外,本文由 开源技术之家 原创编译并授权 开源技术之家 刊载发布。
版权声明:本文不使用任何协议授权,您可以任何形式自由转载或使用。

有好的文章希望我们帮助分享和推广,猛戳这里我要投稿

返回列表
上一篇:

发表评论中国互联网举报中心

快捷回复:

    评论列表 (暂无评论,共304人参与)参与讨论

    还没有评论,来说两句吧...