簡體   English   中英

嘗試連接到 Azure Eventthub 時出錯:AzureTokenCredentials / IllegalArgumentException:名稱

[英]Error when trying to connect to Azure Eventhub: AzureTokenCredentials / IllegalArgumentException: name

我正在關注如何在 Spring 引導中設置與 Azure EventHub 的連接的教程:[1]

啟動 spring 啟動應用程序時,出現以下錯誤:

2021-01-07 13:37:25.447  WARN 16444 --- [           main] ConfigServletWebServerApplicationContext :
Exception encountered during context initialization - cancelling refresh attempt:
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name
'resourceManagerProvider' defined in class path resource
[com/microsoft/azure/spring/cloud/autoconfigure/context/AzureContextAutoConfiguration.class]: Unsatisfied
dependency expressed through method 'resourceManagerProvider' parameter 0; nested exception is 
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name 'azure'
defined in class path resource
[com/microsoft/azure/spring/cloud/autoconfigure/context/AzureContextAutoConfiguration.class]: Unsatisfied
dependency expressed through method 'azure' parameter 0; nested exception is
org.springframework.beans.factory.BeanCreationException: Error creating bean with name 'credentials'
defined in class path resource
[com/microsoft/azure/spring/cloud/autoconfigure/context/AzureContextAutoConfiguration.class]: Bean
instantiation via factory method failed; nested exception is
org.springframework.beans.BeanInstantiationException: Failed to instantiate
[com.microsoft.azure.credentials.AzureTokenCredentials]: Factory method 'credentials' threw exception;
nested exception is java.lang.IllegalArgumentException: name

my.azureauth 看起來類似於 [1] 中的 on。

我正在使用 Java 11。這是我的 pom 的相關部分:

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <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>azure-servicebus-jms-spring-boot-starter</artifactId>
            <version>2.3.5</version>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <!-- Workaround. -->
        <!-- Apparently com.microsoft.azure:spring-cloud-azure-eventhubs-stream-binder:1.2.7 has a transitive -->
        <!-- dependency to the following package. However, it seems that the version is not pinned correctly, so -->
        <!-- we have to pin the version to a compatible one as a workaround. -->
        <!-- 7.5 is apparently the latest version in which com.nimbusds.oauth2.sdk.http.CommonContentTypes is available. -->
        <!-- For a similar (but different) issue see also https://github.com/microsoft/azure-spring-boot/issues/650 -->
        <dependency>
            <groupId>com.nimbusds</groupId>
            <artifactId>oauth2-oidc-sdk</artifactId>
            <version>7.5</version>
        </dependency>

請注意有關依賴com.nimbusds的解決方法。

我嘗試導航到相關代碼。 但是,由於某種原因, AzureContextAutoConfiguration.credentials的代碼在我的 IDE 的反匯編代碼中不可用。

我在pom.xml中的解決方法中使用的版本是否合適? 有誰知道錯誤的含義以及如何解決它? 任何人都可以報告本教程仍然有效嗎?

[1] https://docs.microsoft.com/en-us/azure/developer/java/spring-framework/configure-spring-cloud-stream-binder-java-app-azure-event-hub

所以這里的根本問題是

“無法實例化 [com.microsoft.azure.credentials.AzureTokenCredentials]:工廠方法 'credentials' 拋出異常;嵌套異常是 java.lang.IllegalArgumentException:名稱”

我建議您根據指南再次驗證您的my.azureauthapplication.properties文件。

此外,正如指南所建議的,如果您使用的是 JDK 9 或更高版本(您在這里使用的是 11),請添加以下依賴項

<dependency>
    <groupId>javax.xml.bind</groupId>
    <artifactId>jaxb-api</artifactId>
    <version>2.3.1</version>
</dependency>
<dependency>
    <groupId>org.glassfish.jaxb</groupId>
    <artifactId>jaxb-runtime</artifactId>
    <version>2.3.1</version>
    <scope>runtime</scope>
</dependency>

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM