maven如何推送本地jar到私服

IT 文章2年前 (2023)发布 小编
0 0 0

本文主要讲解关于maven推送本地jar到私服相关内容,让我们来一起了解下吧!

一、推送本地jar包到私服仓库

在任意存在pom文件的目录下运行cmd,执行以下命令。

mvn deploy:deploy-file -DgroupId=com.fkp -DartifactId=http-client-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar -Dfile=C:UsersfengkunpengDesktophttp-client-test-1.0-SNAPSHOT.jar -Durl=http://192.168.200.10/nexus/content/repositories/snapshots/ -DrepositoryId=fkp-snapshots

-DgroupId:groupId

ad

程序员导航

优网导航旗下整合全网优质开发资源,一站式IT编程学习与工具大全网站

-DartifactId:artifactId

-Dversion:version

-Dpackaging:打包方式

-Dfile:文件绝对路径

ad

AI 工具导航

优网导航旗下AI工具导航,精选全球千款优质 AI 工具集

-Durl:私服仓库地址,需时具体的宿主类型仓库

-DrepositoryId:仓库id,需要和settings.xml中server项中id一致

二、安装本地jar包到本地仓库

在任意存在pom文件的目录下运行cmd,执行以下命令。

mvn install:install-file -Dfile=C:UsersfengkunpengDesktophttp-client-test-1.0-SNAPSHOT.jar -DgroupId=com.fkp -DartifactId=http-client-test -Dversion=1.0-SNAPSHOT -Dpackaging=jar

-DgroupId:groupId

-DartifactId:artifactId

-Dversion:version

ad

免费在线工具导航

优网导航旗下整合全网优质免费、免注册的在线工具导航大全

-Dpackaging:打包方式

-Dfile:文件绝对路径

三、常见错误

错误1:

[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (C:UsersfengkunpengDesktop). Please verify you invoked Maven from the correct directory. -> [Help 1]

处理:该错误可能发生在deploy和install中,在任意存在pom文件的目录下执行命令即可,随便找一个maven项目,在根目录下只运行cmd命令即可。

错误2:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-deploy-plugin:2.7:deploy-file (default-cli) on project http-client-test: Failed to deploy artifacts: Could not transfer artifact com.fkp:http-client-test:jar:1.0-20231203.074315-1 from/to Snapshots (http://192.168.200.10:8081/nexus/content/repositories/snapshots/): Failed to transfer file http://192.168.200.10:8081/nexus/content/repositories/snapshots/com/fkp/http-client-test/1.0-SNAPSHOT/http-client-test-1.0-20231203.074315-1.jar with status code 401 -> [Help 1]

处理:该错误可能发生在deploy中,检查命令中-DrepositoryId的值和maven配置文件settings.xml中server项下的id是否一致,且确保server下配置的用户和密码是否有权限访问私服。

以下是settings.xml中部分配置项。

    <servers>
        <server>
            <!--id需要和-DrepositoryId一致-->
            <id>fkp-snapshots</id>
            <username>fengkunpeng</username>
            <password>fkp123456</password>
        </server>
    </servers>

好啦,以上就是关于maven推送本地jar到私服相关的全部内容,希望对你有帮助。欢迎持续关注潘子夜个人博客(www.panziye.com),学习愉快哦![readsource]https://blog.csdn.net/u012785397/article/details/134766123[/readsource]

© 版权声明

相关文章

暂无评论

暂无评论...