【发布时间】:2021-02-17 16:58:12
【问题描述】:
当我构建我的 Maven 管理的 Java 项目时,同一工件的两个版本被安装到构建中(一个战争文件)。我很确定这没关系,但有问题的工件是 com.fasterxml.jackson.core:jackson-annotations 版本 2.7.3 和 2.9.7 .
当我运行 mvn dependency:tree -Dverbose 时,没有出现 jackson-annotations:2.7.3,确实没有出现字符串 2.7.3 在结果输出中的任何位置。
我的问题是,我该如何继续调试这个问题?我相信 dependency:tree 目标会给我完整的传递依赖。这种信念正确吗?如果没有,会怎样?
作为记录,在我的本地机器上找到了新版本的库并且一切正常,但是当部署到另一台机器时部署被破坏,因为该机器找到了旧版本的库。
<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>mygroup</groupId>
<artifactId>something</artifactId>
<version>0.0.48</version>
<packaging>war</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
</properties>
<dependencies>
<dependency>
<groupId>mygroup</groupId>
<artifactId>a</artifactId>
<version>0.0.34</version>
</dependency>
<dependency>
<groupId>mygroup</groupId>
<artifactId>b</artifactId>
<version>0.0.36</version>
</dependency>
<!-- Jersey -->
<dependency>
<groupId>com.sun.xml.bind</groupId>
<artifactId>jaxb-impl</artifactId>
<version>2.1.12</version>
<scope>compile</scope>
</dependency>
<dependency>
<groupId>javax.xml.bind</groupId>
<artifactId>jaxb-api</artifactId>
<version>2.1</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/javax.servlet/javax.servlet-api -->
<dependency>
<groupId>javax.servlet</groupId>
<artifactId>javax.servlet-api</artifactId>
<version>3.0.1</version>
<scope>provided</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.test-framework</groupId>
<artifactId>jersey-test-framework-core</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.containers</groupId>
<artifactId>jersey-container-servlet-core</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<!-- Jersey Test Framework -->
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-server</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.core</groupId>
<artifactId>jersey-client</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>
org.glassfish.jersey.test-framework.providers
</groupId>
<artifactId>
jersey-test-framework-provider-grizzly2
</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.glassfish.jersey.media</groupId>
<artifactId>jersey-media-json-jackson</artifactId>
<version>2.25.1</version>
<scope>test</scope>
</dependency>
</dependencies>
<repositories>
<repository>
<id>myrepository</id>
<name>My repository name</name>
<url>myrepositoryurl</url>
<releases>
<enabled>true</enabled>
</releases>
<snapshots>
<enabled>true</enabled>
</snapshots>
</repository>
</repositories>
<build>
<sourceDirectory>src/main</sourceDirectory>
<testSourceDirectory>src/test</testSourceDirectory>
<resources>
<resource>
<directory>.</directory>
<includes>
<include>pom.xml</include>
</includes>
<filtering>true</filtering>
</resource>
</resources>
<plugins>
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>2.6</version>
<configuration>
<warSourceDirectory>WebContent</warSourceDirectory>
</configuration>
</plugin>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.7.0</version>
<configuration>
<source>1.8</source>
<target>1.8</target>
</configuration>
</plugin>
</plugins>
</build>
</project>
【问题讨论】:
-
我希望 dependency:tree 能找到这个。你是如何建立你的战争的?您可以添加一个简化的 pom 来说明您的问题吗?
-
@tgdavies 我简化了 pom 并将其添加到问题中。你在找什么?
标签: java maven dependencies conflict transitive-dependency