在spring启动服务中应该如何管理springcloudazure依赖关系?

rqcrx0a6  于 2021-06-29  发布在  Java
关注(0)|答案(0)|浏览(230)

有一个spring引导服务,它使用maven的azure sdk for java的几个功能:
微软公司。azure:spring-cloud-azure-eventhubs-stream-binder
微软公司。azure:spring-cloud-azure-appconfiguration-config-web
微软公司。azure:spring-cloud-azure-feature-management-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 这反过来又与 ClientLogger 依赖项中的类 com.azure:azure-core ,出于某种原因,它保留在版本中 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
我尝试了以下解决方案/变通方法:
显式声明依赖项 com.azure:azure-core:1.4.0 . 这解决了上述问题,但会导致其他可传递依赖中的不兼容性,例如。 azure-core-amqp . 此解决方法将导致手动管理所有或多个azure依赖项。
使用 azure-spring-boot-starter 和物料清单:如下所述: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>
...

暂无答案!

目前还没有任何答案,快来回答吧!

相关问题