Maven添加jar到仓库

通过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

 说明:

  1. -Durl:远程仓库的url,例如nexus私服提供的第三方库url是:http://IP:Port/nexus/content/repositories/thirdparty/。
  2. -DrepositoryId:仓库ID,这与私服中的ID毫无关系,而是标识部署远程仓库需要用户名和密码。首先在maven的settings.xml中配置远程仓库的用户名和密码:

      

<server>  
    <id>nexus</id>  
    <username>deploy</username>  
    <password>deploy</password>  
</server>

         DrepositoryId必须与server的id相一致。

 

 

你可能感兴趣的:(maven,jar,仓库)