我在我创建的 git 存储库中为我的文件提供了 jar,其中 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 导入一个额外的 graphframes jar ,其依赖关系如下:
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).
关于java - 除了 git repo 中的 jar 之外,还从 mvn repo 导入依赖项,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46467203/