标签: transitive-dependency

maven - 如何解决此错误:“XXX 的 POM 无效”?

我正在使用 Maven 构建一个简单的项目。我无法构建它,因为缺少传递依赖项,即objenesis 1.0.

我在调试模式下运行 Maven 并收到以下消息:

[DEBUG] =======================================================================
[WARNING] The POM for org.jmock:jmock-junit4:jar:2.6.0 is invalid, transitive dependencies (if any) will not be available: 1 problem was encountered while building the effective model for org.jmock:jmock-junit4:2.6.0
[ERROR] Invalid packaging for parent POM org.jmock:jmock-parent:2.6.0, must be "pom" but is "jar" @ org.jmock:jmock-parent:2.6.0
...
Run Code Online (Sandbox Code Playgroud)

当我查看 jmock-parent 时,我似乎找不到对 pom 或 jar 类型的引用。

我该如何解决这个问题?

注意:我们使用我们公司的 Nexus 来获取依赖项。


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>
<groupId>Poc</groupId>
<artifactId>Poc</artifactId>
<version>0.0.1-SNAPSHOT</version>

<properties>
    <maven.compiler.source>1.6</maven.compiler.source>
    <maven.compiler.target>1.6</maven.compiler.target>
</properties>

<dependencies> …
Run Code Online (Sandbox Code Playgroud)

java dependencies jmock maven transitive-dependency

3
推荐指数
1
解决办法
1万
查看次数

如果它们来自父级的其他子模块,我是否应该依赖Maven中的传递依赖项?

假设我们正在研究抵押子模块,并且直接Google Guava在模块代码中使用这些类,但是的依赖关系guava是在同一父对象下的其他子模块中定义的,并且只能通过对“投资”模块:

banking-system (parent pom.xml)
|
|-- investment (pom.xml defines <dependency>guava</dependency>)
|
|-- mortgage (pom.xml defiens <dependency>investment</dependency>)
Run Code Online (Sandbox Code Playgroud)

我们还应该<dependency>抵押pom.xml中为Guava 放置一个吗?

缺点看起来像我们pom.xml中的副本,优点是:如果开发“投资”的人会丢弃番石榴,那么它不会阻止我们的抵押子模块成功构建。

如果是,那么<version>我们指定什么方法?(<dependencyManagement>在父pom中没有+ ?)

如果是,那么我们应该<provided>在某个模块中使用范围吗?

注意:请记住,我是在特定情况下询问模块具有共同的父pom(例如,作为一个整体的应用程序)。

想象一下,也许这种结构不是最好的例子:

banking-app
    banking-core (dep.on: guava, commons, spring)
    investment (dep.on: banking-core)
    mortgage (dep.on: banking-core)
Run Code Online (Sandbox Code Playgroud)

Investment使用Spring时仍应该显式声明Spring @Component,如果使用Guava则声明Guava LoadedCache

dependencies pom.xml maven transitive-dependency parent-pom

3
推荐指数
1
解决办法
1291
查看次数

在Jena上使用OPTION(TRANSITIVE)进行SPARQL查询错误

我有以下查询

PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?type
WHERE
{
   {
      SELECT *
      WHERE
      {
           ?x rdfs:subClassOf ?type .
      }
   }
   OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) .
   FILTER (?x = <http://dbpedia.org/ontology/Hospital>)
}
Run Code Online (Sandbox Code Playgroud)

当我将它发送到Virtuoso端点但它在我的Jena实例上不起作用时它工作正常.具体我得到以下错误:

INFO  [1] 400 Parse error: 
PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#>
SELECT ?type
WHERE
{
   {
      SELECT *
      WHERE
      {
           ?x rdfs:subClassOf ?type .
      }
   }
   OPTION (TRANSITIVE, t_distinct, t_in (?x), t_out (?type) ) .
   FILTER (?x = <http://dbpedia.org/ontology/Hospital>)
}
Lexical error at line 12, column 39.  Encountered: " …
Run Code Online (Sandbox Code Playgroud)

sparql jena virtuoso transitive-dependency fuseki

2
推荐指数
1
解决办法
734
查看次数

如何在Maven中调试工件替换

我有一个父项目包含十几个子项目,其中一个子项目使用org.apache.httpcomponents:httpclient:jar:4.3.5,这取决于org.apache.httpcomponents:httpcore:jar:4.3.2.

但是,结果版本httpcore被解析为4.2.1而不是4.3.2.

以下是dependency:tree在Eclipse中选中调试选项运行时的输出提取:

...
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
[DEBUG]   testArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG]   includeArtifact: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG]   startProcessChildren: artifact=org.apache.httpcomponents:httpclient:jar:4.3.5:compile
[DEBUG]     manageArtifactVersion: artifact=org.apache.httpcomponents:httpcore:jar:4.3.2:compile, replacement=org.apache.httpcomponents:httpcore:jar:4.2.1
[DEBUG] Using mirror nexus (http://192.168.0.111:8081/nexus/content/groups/public) for apache.snapshots (http://repository.apache.org/snapshots).
...
Run Code Online (Sandbox Code Playgroud)

它只是显示replacement=org.apache.httpcomponents:httpcore:jar:4.2.1,但它没有说明更换的原因.父项目的pom.xml使用了很多依赖项,即使我可以尝试逐个删除这些依赖项并检查结果,但这将非常耗时.有没有更有效的方法来调试工件更换?


这里几乎是dependency:treeEclipse 的完整日志,并且选中了调试选项.

artifact pom.xml maven transitive-dependency

2
推荐指数
1
解决办法
2860
查看次数

Maven相同的传递依赖项但版本不同

我遇到一个具有以下2个依赖项的问题:

org.apache.felix»org.apache.felix.utils»1.6.0

com.github.rotty3000»phidias»0.3.2

它们都对org.osgi.core具有传递依赖关系,felix依赖于版本4.1.0,phidias依赖于版本5.0.0

我们需要版本5.0.0才能正确编译我们的代码

如果我将依赖项设为:

<dependencies>
    <dependency>
        <groupId>org.apache.felix</groupId>
        <artifactId>org.apache.felix.utils</artifactId>
        <version>1.6.0</version>
        <scope>compile</scope>
    </dependency>
    <dependency>
        <groupId>com.github.rotty3000</groupId>
        <artifactId>phidias</artifactId>
        <version>0.3.2</version>
        <scope>compile</scope>
    </dependency>
</dependencies>
Run Code Online (Sandbox Code Playgroud)

maven自动获取版本4.1.0,导致编译错误。如果我将phidias放在felix之上,它将获得版本5.0.0并可以正常编译。

我们要按字母顺序对依赖项进行排序,以便felix排在最前面,是否仍然有必要强制osgi.core解析5.0.0版本?

谢谢!

dependencies maven transitive-dependency

2
推荐指数
1
解决办法
335
查看次数

从 Maven pom 中排除传递依赖

我在 typetest-jar和 scope 的位置添加了一个 Maven 依赖项test。我想从中删除传递依赖项(因为在 Nexus prod 存储库中缺少此依赖项,这会导致 Jenkins 构建失败)。我添加了一个排除标签,但仍然没有删除依赖项,即 Jenkins 构建仍然失败并抱怨这个依赖项。任何线索为什么?

    <dependency>
        <groupId>com.xxx</groupId>
        <artifactId>xxx</artifactId>
        <type>test-jar</type>
        <version>${xxx.version}</version>
        <scope>test</scope>
        <exclusions>
            <exclusion>
                <artifactId>jamon</artifactId>
                <groupId>com.jamonapi</groupId>
                <!-- <scope>compile</scope> -->
            </exclusion>
        </exclusions>
    </dependency>
Run Code Online (Sandbox Code Playgroud)

dependency-management maven transitive-dependency

1
推荐指数
1
解决办法
2668
查看次数