【问题标题】:Workaround to maven's "Failed to resolve artifact" in non-trivial dependenciesmaven 在非平凡依赖项中“无法解析工件”的解决方法
【发布时间】:2011-05-22 19:22:00
【问题描述】:

在构建旧项目时,有时我会遇到可怕的Failed to resolve artifact 错误。

然后我要做的是搜索该特定工件的jarpom 并使用mvn install:install-file goal to manually install it locally

这解决了琐碎的情况,但有时项目对工件的依赖并不琐碎,包括在项目的 pom 字段中,例如:

      <scope>runtime</scope>

或更糟:

      <exclusion>
        <groupId>cglib</groupId>
        <artifactId>cglib-nodep</artifactId>
      </exclusion>

您将如何处理这些情况?有没有办法将这些字段也添加到命令中?

【问题讨论】:

    标签: java maven dependencies


    【解决方案1】:

    运行时依赖项是 Maven 将添加到测试类路径中的,并包含在程序集或战争中,但不会包含在编译类路径中。如果您需要运行测试或打包,您只需执行完全相同的 install:install-file 操作(或者,更好的是,运行 repo 管理器并部署它)。运行时是一个作用域

    另一方面,如果你遇到了:

    <dependency>
       <groupId>abelian</groupId>
       <artifactId>grape</groupId>
       <type>transitive</type>
    </dependency>
    

    然后您需要使用 -Dpackaging=transitive 来安装:安装文件,类似地用于“分类器”(-Dclassifier)。

    如果您需要在 pom 中有一个排除项的依赖关系树中添加一些内容,那么您将需要找到或构建一个具有该排除项的 POM,并将其传递给 install-file 目标,该目标具有-D 用于 POM。没有什么可以告诉 install:install-file 告诉它在凭空构建 POM 时添加排除项。

    【讨论】:

      猜你喜欢
      • 2012-01-12
      • 2017-05-06
      • 2014-05-03
      • 2017-01-06
      • 2011-08-01
      • 2017-03-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多