繁体   English   中英

除了 git repo 中的 jars 之外,还从 mvn repo 导入依赖项

[英]Importing dependency from mvn repo in addition to jars in git repo

我在我创建的 git repo 中为我的文件提供了 jars,其中 pom.xml 为

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>com.acc.ar</groupId>
        <artifactId>ar-anal-plat</artifactId>
        <version>1.6.0-RC-SNAPSHOT</version>
    </parent>
    <artifactId>gr-anal-app</artifactId>

    <dependencies>
        <dependency>
            <groupId>com.acc.ar</groupId>
            <artifactId>ar-anal-core</artifactId>
        </dependency>
        <dependency>
            <groupId>com.acc.ar</groupId>
            <artifactId>ar-anal-core-test</artifactId>
            <scope>test</scope>
        </dependency>
    </dependencies>
</project>

我想从具有依赖关系的 mvn repo 导入一个额外的图形帧罐子,如下所示:
https://mvnrepository.com/artifact/graphframes/graphframes/0.5.0-spark2.1-s_2.11

我必须在 pom 文件中进行哪些更改?

maven 中有 3 种类型的存储库:

1)本地存储库:本地系统上的一个位置,用于第一次存储从中央或远程存储库下载的jar,从第二次开始,首先在本地存储库中搜索依赖项,如果不存在,则转到中央存储库:它的位置需要在 maven 的setting.xml文件中提及。

2)中央存储库:它是所有项目相关依赖项的集中位置,它的位置需要在setting.xml文件中提供。 我希望你已经在 setting.xml 文件中提到了“git repo”。

3)远程存储库:如果本地或中央存储库中不存在任何依赖项,则可以在 pom.xml 文件中提供自定义位置。 因此,首先它会查看本地存储库,如果不存在,然后是中央存储库,然后是远程存储库。

<repositories>
  <repository>
     <id>companyname.lib1</id>
     <url>http://download.companyname.org/maven2/lib1</url>
  </repository>
  <repository>
     <id>companyname.lib2</id>
     <url>http://download.companyname.org/maven2/lib2</url>
  </repository>

在您的情况下使用它,我想您的问题应该得到解决。

搜索顺序:

Step 1 − Search dependency in local repository, if not found, move to step 2 else perform the further processing.

Step 2 − Search dependency in central repository, if not found and remote repository/repositories is/are mentioned then move to step 4. Else it is downloaded to local repository for future reference.

Step 3 − If a remote repository has not been mentioned, Maven simply stops the processing and throws error (Unable to find dependency).

Step 4 − Search dependency in remote repository or repositories, if found then it is downloaded to local repository for future reference. Otherwise, Maven stops processing and throws error (Unable to find dependency).

在依赖项块中,您需要插入以下内容:

   <!-- https://mvnrepository.com/artifact/graphframes/graphframes -->
   <dependency>
       <groupId>graphframes</groupId>
       <artifactId>graphframes</artifactId>
       <version>0.5.0-spark2.1-s_2.11</version>
   </dependency>

然后很可能在 IDE 中刷新项目/导入更改。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM