尝试连接到 Azure Eventhub 时出错: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。
我正在使用 Java11。这是我的 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
的解决方法中使用的版本是否合适?
有谁知道错误的含义以及如何解决?
谁能报告说本教程仍然有效?
所以这里的根本问题是
"Failed to instantiate
[com.microsoft.azure.credentials.AzureTokenCredentials]: Factory method 'credentials' threw exception;
nested exception is java.lang.IllegalArgumentException: name"
我建议您根据 guide.
再次验证您的 my.azureauth
和 application.properties
文件
此外,正如 guide 所建议的,如果您使用的是 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>
我正在学习如何在 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。
我正在使用 Java11。这是我的 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
的解决方法中使用的版本是否合适?
有谁知道错误的含义以及如何解决?
谁能报告说本教程仍然有效?
所以这里的根本问题是
"Failed to instantiate [com.microsoft.azure.credentials.AzureTokenCredentials]: Factory method 'credentials' threw exception; nested exception is java.lang.IllegalArgumentException: name"
我建议您根据 guide.
再次验证您的my.azureauth
和 application.properties
文件
此外,正如 guide 所建议的,如果您使用的是 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>