簡體   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