【问题标题】:Maven 3.8.1 How to direct dependencies in pom to the right location and not take the repo url from settings.xmlMaven 3.8.1 如何将 pom 中的依赖项定向到正确的位置,而不是从 settings.xml 获取 repo url
【发布时间】:2022-06-10 20:40:30
【问题描述】:

我有一个带有 selenium-java、com.saucelabs 等依赖项的 pom,以及带有指向 JFrog 存储库的 url 的存储库。对于 JFrog repo 中的工件,我已经注释掉了 conf/settings.xml 中的块,因为它是 HTTP。我在.m2/settings.xml 中列出了回购协议。 我在运行mvn install时遇到了这个错误

Could not resolve dependencies for project com.github.frameworkium:frameworkium-core:jar:4.0.0-BETA2-SNAPSHOT: Failed to collect dependencies at org.seleniumhq.selenium:selenium-java:jar:4.1.1: Failed to read artifact descriptor for org.seleniumhq.selenium:selenium-java:jar:4.1.1: Could not transfer artifact org.seleniumhq.selenium:selenium-java:pom:4.1.1 from/to snapshots (http://xxx-xxx.xxx/artifactory/libs-snapshot-local)

在将 Jfrog repo url 添加到 settings.xml 之前,我能够成功提取依赖项。 我应该在 settings.xml 中更改/添加什么以从正确的位置提取所有依赖项,例如 selenium-java,并从 JFrog repo url 提取存储库。

【问题讨论】:

  • settings.xml 文件必须位于您的主目录$HOME/.m2/settings.xml 并且NOT$HOME/.m2/repository/settings.xml...
  • @khmarbaise 抱歉,我已经编辑了上面的评论。我在 .m2 中有设置文件,而不是存储库。所有依赖项都指向 JFrog 存储库而不是它自己的。我是 maven 新手,所以不知道如何将依赖项 selenium-java/jacoco/google/log4j 等指向它的 maven 依赖项而不是 JFrog。
  • 如果你正在使用 jfrog,我想你是在一个必须使用它的公司环境中......
  • 是的,没错。这是否意味着我也必须将所有 selenium 依赖项添加到存储库中,我不确定是否可以。
  • 如果你的存储库没有提供你需要的deps,那就有问题了......回购管理器应该连接到互联网并且应该可以工作......

标签: selenium maven-3


【解决方案1】:

感谢@khmarbaise。我能够从正确的位置获取 deps。我添加了 central 指向 maven repo 和其他依赖项指向 Jfrog repo。

 <repository>
     <snapshots>
        <enabled>false</enabled>
     </snapshots>
         <id>central-artifactory</id>
         <name>libs-release</name>
         <url>http://xxxx.xxx/artifactory/libs-releaselocal</url>
 </repository>
 <repository>
         <snapshots />
         <id>snapshots-artifactory</id>
         <name>libs-snapshot</name>
         <url>http://xxxx.xxx/artifactory/libs-releaselocal</url>
 </repository>
 <repository>
         <id>central</id>
         <name>Central Repository</name>
         <url>https://repo.maven.apache.org/maven2</url>
         <layout>default</layout>
         <snapshots>
            <enabled>false</enabled>
         </snapshots>
  </repository>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-07-08
    • 2011-07-25
    • 2022-12-06
    • 1970-01-01
    • 2011-04-03
    • 2016-06-05
    • 1970-01-01
    相关资源
    最近更新 更多