Azure与Jackson的依赖关系冲突:java.lang.LinkageError:软件包版本

piwo6bdm  于 2023-08-07  发布在  Java
关注(0)|答案(1)|浏览(226)

我在将azure storage sdk引入我的Java项目时遇到了麻烦。很明显,不同的Jackson依赖版本之间存在冲突,但奇怪的是,导入的所有依赖都是相同的最新版本。
Azure依赖项:

<dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-sdk-bom</artifactId>
        <version>1.2.14</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
<dependencies>
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-storage-blob</artifactId>
    </dependency>
...
</dependencies>

字符串
触发问题的代码:

BlobServiceClient blobServiceClient = new BlobServiceClientBuilder()
                .connectionString(connectionString)
                .buildClient();
blobServiceClient.createBlobContainer("hello-world-" + UUID.randomUUID());


问题是:

ERROR [com.azure.core.implementation.jackson.ObjectMapperShim] (reactor-http-nio-1) Package versions: jackson-core=2.12.6, jackson-databind=2.12.6-1, jackson-dataformat-xml=2.15.2, jackson-datatype-jsr310=2.12.6, azure-core=1.40.0, Troubleshooting version conflicts: https://aka.ms/azsdk/java/dependency/troubleshoot
...
Caused by: java.lang.NoSuchMethodError: com.fasterxml.jackson.core.io.ContentReference com.fasterxml.jackson.core.io.IOContext.contentReference()'
    at deployment.psMobileServerAdminConsole-${acp.version}.war//com.fasterxml.jackson.dataformat.xml.deser.FromXmlParser.<init>(FromXmlParser.java:263)
    at deployment.psMobileServerAdminConsole-${acp.version}.war//com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:653)
    at deployment.psMobileServerAdminConsole-${acp.version}.war//com.fasterxml.jackson.dataformat.xml.XmlFactory._createParser(XmlFactory.java:30)
    at com.fasterxml.jackson.core.jackson-core@2.12.6//com.fasterxml.jackson.core.JsonFactory.createParser(JsonFactory.java:1124)
    at com.fasterxml.jackson.core.jackson-databind@2.12.6.1//com.fasterxml.jackson.databind.ObjectMapper.readValue(ObjectMapper.java:3643)


奇怪的是,我没有显式地或以传递的方式导入这些2.12.6依赖项-我只使用2.15.2
Jackson dependencies screenshot from IDE
完整依赖关系树:https://github.com/lrd2/working/blob/main/dependency_tree.txt
那么,你知道是什么导致了冲突,以及如何解决冲突吗?

0g0grzrc

0g0grzrc1#

这是一个WildFly服务器,我部署了应用程序,导致了问题。它用预定义的依赖项覆盖了应用程序中配置的Jackson依赖项。在WildFly配置中替换它们后,问题消失了,Azure SDK创建了blob容器。

相关问题