上传jar包依赖到maven私服的操作方法

编程入门 行业动态 更新时间:2024-10-25 14:26:43

上传jar包依赖到maven<a href=https://www.elefans.com/category/jswz/34/1761480.html style=私服的操作方法"/>

上传jar包依赖到maven私服的操作方法

1、配置maven的settings文件

<servers>

    <server>

        <id>releases</id>

        <username>deployment</username>

        <password>deployment123</password>

    </server>

    <server>

        <id>snapshots</id>

        <username>deployment</username>

        <password>deployment123</password>

    </server>

</servers>

其中id对应着nexus私服的仓库id,如果要上传到其它仓库,同样需要在settings文件中进行相关配置即可。

 

用户名和密码对应nexus中设置的用户名密码,在Security->Users中,在对应的用户名上右键-> Set Password进行设置。

 

2、修改仓库权限

需要将对应的仓库权限改成Allow Redeploy,点击仓库名->Configuration

 

3、配置pom.xml文件

<repositories>

    <repository>

        <id>nexus</id>

        <name>nexus</name>

        <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

        <releases>

            <enabled>true</enabled>

        </releases>

        <snapshots>

            <enabled>true</enabled>

        </snapshots>

    </repository>

</repositories>

 

<pluginRepositories>

    <pluginRepository>

        <id>nexus</id>

        <name>nexus</name>

        <url>http://127.0.0.1:8081/nexus/content/groups/public/</url>

        <releases>

            <enabled>true</enabled>

        </releases>

        <snapshots>

            <enabled>true</enabled>

        </snapshots>

    </pluginRepository>

</pluginRepositories>

 

 

<distributionManagement>

    <repository>

        <id>releases</id>

        <name>User Project Release</name>

        <url>http://127.0.0.1:8081/nexus/content/repositories/releases/</url>

    </repository>

       <snapshotRepository>

          <id>snapshots</id>

          <name>User Project SNAPSHOTS</name>

        <url>http://127.0.0.1:8081/nexus/content/repositories/snapshots/</url>

       </snapshotRepository>

</distributionManagement>

 

4、上传jar包命令

mvn deploy:deploy-file -DgroupId=com.oracle -DartifactId=jdbc14 -Dversion=1.0.0 -Dpackaging=jar -Dfile=C:\Users\wangc\.m2\repository\mysql\mysql-conn

ector-java\5.1.42\mysql-connector-java-5.1.42.jar -Durl=http://127.0.0.1:8081/nexus/content/repositories/releases/ -DrepositoryId=releases -X

其中DgroupId和DartifactId构成了该jar包在pom.xml的坐标,项目就是依靠这两个属性定位。

Dfile表示需要上传的jar包的绝对路径。 

Durl私服上仓库的位置,打开nexus->repositories菜单,可以看到该路径。 

DrepositoryId表示仓库id,在nexus的配置信息中可以找到。

-X表示输出全部日志,如果有报错可以看到详细的报错信息

 

注意:如果报错Cannot deploy artifact from the local repository,是因为要安装的jar和pom不能是位于本地repository的目录下,将要安装的jar和pom copy到其它目录再安装。

除了可以上传jar包之外,还可以pom

mvn deploy:deploy-file -Dfile=[your file] -DgroupId=[xxxx] -DartifactId=[xxxx] -Dversion=[xxxx] -Dpackaging=[pom|jar|other] -DrepositoryId=[id] -Durl=[repo url]

 

 

 

 

 

 

更多推荐

上传jar包依赖到maven私服的操作方法

本文发布于:2024-03-04 00:09:33,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1707741.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:私服   操作方法   上传   maven   jar

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!