如何将已有jar包手动添加到本地Maven库中

时间:2021-05-03 09:06:39

1.情况说明:Maven的远程仓库连接的时候,搜索太慢,故在~/.m2文件目录下的setting中制定本地非C盘Maven仓库,同时将其中的镜像仓库<mirrors>标签中注释的<mirror>标签解开,配国内镜像仓库
如下:

 
<mirrors>
    <!-- mirror
     | Specifies a repository mirror site to use instead of a given repository. The repository that
     | this mirror serves has an ID that matches the mirrorOf element of this mirror. IDs are used
     | for inheritance and direct lookup purposes, and must be unique across the set of mirrors.
     |
    <mirror>
      <id>mirrorId</id>
      <mirrorOf>repositoryId</mirrorOf>
      <name>Human Readable Name for this Mirror.</name>
      <url>http://my.repository.com/repo/path</url>
    </mirror>
     -->
    <mirror>
      <id>alimaven</id>
      <name>aliyun maven</name>
      <url>http://maven.aliyun.com/nexus/content/groups/public/</url>
      <mirrorOf>central</mirrorOf>        
    </mirror>
  </mirrors>

 

2.配国内镜像仓库,但是此仓库中jar包并不像*仓库那么全....可以去以下常用网站下载

http://mvnrepository.com/
http://search.maven.org/
http://repository.sonatype.org/content/groups/public/
http://people.apache.org/repo/m2-snapshot-repository/
http://people.apache.org/repo/m2-incubating-repository/

3.下载你想要的版本到本地
如何将已有jar包手动添加到本地Maven库中

例如:ojdbc-14-10gR3.jar   点击"DownLoad()JAR)"

如何将已有jar包手动添加到本地Maven库中

4.下载到本地后,去ojdbc-14-10gR3.jar,所在文件夹中打开dos命令窗口,对照上图,输入一下命令即可添加

 
    
mvn install:install-file -Dfile=ojdbc-14-10gR3.jar -DgroupId=ojdbc -DartifactId=ojdbc -Dversion=14-10gR3 -Dpackaging=jar