有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何在springboot服务中管理springcloudazure依赖关系?

有一个spring引导服务,它使用了使用maven的azure sdk for java中的几个特性:

  • com。微软azure:SpringCloudAzure事件集线器流绑定器
  • com。微软azure:spring云azure应用程序配置web
  • com。微软azure:SpringCloudAzure功能管理web

目前,依赖项版本是手动管理的(不使用BOM/<depencecyManagement>元素:

        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>spring-cloud-azure-eventhubs-stream-binder</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>spring-cloud-azure-appconfiguration-config-web</artifactId>
            <version>1.2.7</version>
        </dependency>
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>spring-cloud-azure-feature-management-web</artifactId>
            <version>1.2.7</version>
        </dependency>

在将spring-cloud-azure-eventhubs-stream-binder依赖项升级到下一个可用版本1.2.8后,但其他版本不升级,因为没有更新的版本可供使用,我遇到了运行时错误,因为新的eventhub依赖项引入了更新版本的可传递依赖项com.azure:azure-core-amqp,而该依赖项又与依赖项com.azure:azure-core中的ClientLogger类不兼容,出于某种原因,该类保留在版本1.3.0

由此产生的错误是:

java.lang.NoSuchMethodError: 'void com.azure.core.util.logging.ClientLogger.warning(java.lang.String)'
    at com.azure.core.amqp.implementation.AmqpChannelProcessor.onSubscribe(AmqpChannelProcessor.java:69)

那么,在一个spring boot微服务中实现一组一致的spring cloud azure依赖项的预期方式是什么呢

此演示项目可重现此问题: https://github.com/ulrichwinter/azure-eventhub-demo

我尝试了以下解决方案/变通方法:

  1. 显式地将依赖项声明为com.azure:azure-core:1.4.0。 这解决了上述问题,但会导致其他可传递依赖项中的不兼容性,例如azure-core-amqp。此解决方法将导致手动管理所有或多个azure依赖项

  2. 使用azure-spring-boot-starter和BOM: 如下所述: https://docs.microsoft.com/de-de/azure/developer/java/spring-framework/spring-boot-starters-for-azure 将以下元素添加到pom不会改变任何东西,因为仍然需要显式声明所用eventhub和appconfig依赖项的版本:

        <properties>
            <azure.version>2.3.5</azure.version>
        </properties>
...
        <dependency>
            <groupId>com.microsoft.azure</groupId>
            <artifactId>azure-spring-boot-starter</artifactId>
        </dependency>
...
    <dependencyManagement>
        <dependencies>
            <dependency>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>azure-spring-boot-bom</artifactId>
                <version>${azure.version}</version>
                <type>pom</type>
                <scope>import</scope>
            </dependency>
        </dependencies>
    </dependencyManagement>
...

共 (0) 个答案