java Sping Boot 应用程序中azure-storage-blob的不同依赖关系

nzkunb0c  于 2023-10-14  发布在  Java
关注(0)|答案(1)|浏览(91)

我有两个不同的使用same azure-storage-blob依赖的**Sping Boot **项目。
当我运行下面给出的maven命令时:

mvn dependency:tree

我看到azure-storage-blob有两种不同的依赖关系。
对于第一个应用程序:

+- com.azure:azure-storage-blob:jar:12.23.0:compile
|  |  |  +- com.azure:azure-core:jar:1.41.0:compile
|  |  |  |  \- com.azure:azure-json:jar:1.0.1:compile
|  |  |  +- com.azure:azure-core-http-netty:jar:1.13.5:compile
|  |  |  |  +- io.netty:netty-codec-http2:jar:4.1.59.Final:compile
|  |  |  |  +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.59.Final:compile
|  |  |  |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.59.Final:compile
|  |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:2.0.36.Final:compile
|  |  |  |  \- io.projectreactor.netty:reactor-netty-http:jar:1.0.33:compile
|  |  |  |     +- io.netty:netty-resolver-dns:jar:4.1.59.Final:compile
|  |  |  |     |  \- io.netty:netty-codec-dns:jar:4.1.59.Final:compile
|  |  |  |     +- io.netty:netty-resolver-dns-native-macos:jar:osx-x86_64:4.1.59.Final:compile
|  |  |  |     \- io.projectreactor.netty:reactor-netty-core:jar:1.0.33:compile
|  |  |  +- com.azure:azure-storage-common:jar:12.22.0:compile
|  |  |  \- com.azure:azure-storage-internal-avro:jar:12.8.0:compile
|  |  +- com.azure:azure-identity:jar:1.9.2:compile
|  |  |  +- com.microsoft.azure:msal4j:jar:1.13.8:compile
|  |  |  \- com.microsoft.azure:msal4j-persistence-extension:jar:1.2.0:compile
|  |  +- io.netty:netty-resolver:jar:4.1.59.Final:compileenter code here

对于第二个应用程序:

+- com.azure:azure-storage-blob:jar:12.23.0:compile
[INFO] |  +- com.azure:azure-core:jar:1.41.0:compile
[INFO] |  |  +- com.azure:azure-json:jar:1.0.1:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-annotations:jar:2.13.5:compile
[INFO] |  |  +- com.fasterxml.jackson.core:jackson-databind:jar:2.13.5:compile
[INFO] |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.5:compile
[INFO] |  |  \- io.projectreactor:reactor-core:jar:3.4.32:compile
[INFO] |  |     \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
[INFO] |  +- com.azure:azure-core-http-netty:jar:1.13.5:compile
[INFO] |  |  +- io.netty:netty-handler:jar:4.1.97.Final:compile
[INFO] |  |  |  +- io.netty:netty-resolver:jar:4.1.97.Final:compile
[INFO] |  |  |  \- io.netty:netty-transport:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-handler-proxy:jar:4.1.97.Final:compile
[INFO] |  |  |  \- io.netty:netty-codec-socks:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-buffer:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-codec:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-codec-http:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-codec-http2:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-unix-common:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.97.Final:compile
[INFO] |  |  |  \- io.netty:netty-transport-classes-epoll:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.97.Final:compile
[INFO] |  |  |  \- io.netty:netty-transport-classes-kqueue:jar:4.1.97.Final:compile
[INFO] |  |  +- io.netty:netty-tcnative-boringssl-static:jar:2.0.61.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-classes:jar:2.0.61.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.61.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.61.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.61.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.61.Final:compile
[INFO] |  |  |  \- io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.61.Final:compile
[INFO] |  |  +- io.projectreactor.netty:reactor-netty-http:jar:1.0.35:compile
[INFO] |  |  |  +- io.netty:netty-resolver-dns:jar:4.1.97.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-codec-dns:jar:4.1.97.Final:compile

虽然这两个应用程序都使用12.23.0版本的azure-storage-blob的相同依赖项,但从输出中可以看出,azure-storage-blob对不同版本具有不同的依赖项。
io.netty:netty-resolver:jar:4.1.97.Final
在第二个应用程序中,
io.netty:netty-resolver:jar:4.1.59.Final
在第一个应用程序中,
是什么导致了这种差异,以及如何找到哪些依赖实际上带来了这些不同的依赖?
先谢了。
UPD:在第一个应用程序(有问题)的pom.xml中,有以下定义:

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-storage-blob</artifactId>
    <version>12.23.0</version>
    <exclusions>
    <exclusion>
        <groupId>io.netty</groupId>
        <artifactId>netty-resolver</artifactId>
    </exclusion>
</exclusions>
</dependency>

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.9.2</version>
</dependency>

<!-- Netty -->
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-handler</artifactId>
    <version>4.1.97.Final</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-handler-proxy</artifactId>
    <version>4.1.97.Final</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-buffer</artifactId>
    <version>4.1.97.Final</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-codec-http</artifactId>
    <version>4.1.97.Final</version>
</dependency>
<dependency>
    <groupId>io.netty</groupId>
    <artifactId>netty-resolver</artifactId>
    <version>4.1.97.Final</version>
</dependency>

已尝试从azure-storage-blob依赖项中排除netty-resolver依赖项+添加了按netty-resolver版本的显式导入,但仍导入了版本4.1.59。这也是重要的命令吗?谢谢
例外情况:

java.lang.NoClassDefFoundError: reactor/netty/http/client/HttpClient

    at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:154)
    at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:56)
    at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:62)
    at com.azure.core.implementation.http.HttpClientProviders.lambda$createInstance$0(HttpClientProviders.java:46)
    at com.azure.core.implementation.util.Providers.create(Providers.java:114)
    at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:46)
    at com.azure.core.http.HttpClient.createDefault(HttpClient.java:61)
    at com.azure.core.http.HttpClient.createDefault(HttpClient.java:51)
    at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:78)
    at com.azure.storage.blob.implementation.util.BuilderHelper.buildPipeline(BuilderHelper

第3页:pom.xml的一部分-第二个应用程序-工作:

<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter</artifactId>
</dependency>
<dependency>
    <groupId>org.springframework.boot</groupId>
    <artifactId>spring-boot-starter-test</artifactId>
    <scope>test</scope>
</dependency>
<dependency>
    <groupId>com.nimbusds</groupId>
    <artifactId>oauth2-oidc-sdk</artifactId>
    <version>6.15</version>
</dependency>
<dependency>
    <groupId>org.springframework</groupId>
    <artifactId>spring-context</artifactId>
</dependency>
<dependency>
    <groupId>com.microsoft.azure</groupId>
    <artifactId>azure-storage</artifactId>
    <version>4.2.0</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-storage-blob</artifactId>
    <version>12.23.0</version>
</dependency>
<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-identity</artifactId>
    <version>1.9.2</version>
</dependency>

其他差异:对于第一个应用程序(有问题),将Azure功能添加到现有代码中。第二个应用(Working)由Spring Initializr生成,并添加了azure导入

dced5bon

dced5bon1#

很明显你分享的日志里有。
io.netty:netty-resolver-dns:jar:4.1.97.Final来自第二个应用程序中的io.projectreactor.netty:reactor-netty-http:jar:1.0.35

io.netty:netty-resolver:jar:4.1.59.Final来自第一个应用中的com.azure:azure-storage-blob:jar:12.23.0
基本上,第二个应用程序省略了使用来自com.azure:azure-storage-blob:jar:12.23.0io.netty:netty-resolver:jar:4.1.59.Final,而是选择了来自reactor-netty-http的应用程序,因为它使用的是最新版本的netty-resolver-dns (4.1.97.Final)
简而言之,如果发现多个相同的依赖项,Maven会优先考虑更新/更高的版本。

相关问题