通过maven下载构件时,通常有一些构件在中央仓库找不到,比如oracle的驱动,这种情况就要手动添加到仓库中。
添加jar包到本地库
mvn install:install-file -Dfile=***.jar -DgroupId=组织名称 -DartifactId=项目名称 -Dversion=版本 -Dpackaging=jar
添加jar包到远程库
mvn deploy:deploy-file -Dfile=***.jar -DgroupId=组织名称 -DartifactId=项目名称 -Dversion=版本 -Dpackaging=jar -Durl=http://远程库url -DrepositoryId=仓库ID
说明:
- -Durl:远程仓库的url,例如nexus私服提供的第三方库url是:http://IP:Port/nexus/content/repositories/thirdparty/。
- -DrepositoryId:仓库ID,这与私服中的ID毫无关系,而是标识部署远程仓库需要用户名和密码。首先在maven的settings.xml中配置远程仓库的用户名和密码:
<server>
<id>nexus</id>
<username>deploy</username>
<password>deploy</password>
</server>
DrepositoryId必须与server的id相一致。
本文介绍如何使用Maven命令将特定的jar包安装到本地仓库或部署到远程仓库中,包括必要的参数配置。

被折叠的 条评论
为什么被折叠?



