我正在开发一个要在应用程序中上传的 jar 文件,该应用程序将利用它连接到 azure 密钥保管库并检索凭据以进一步在服务器上运行一些操作。我正在使用 maven,并陷入此错误:
java.lang.noclassdeffounderror: reactor/netty/transport/clienttransport at java.base/java.lang.classloader.defineclass1(native method)
这是代码部分:
clientcertificatecredential clientcertificatecredential = new clientcertificatecredentialbuilder() .tenantid(tenantid) .clientid(clientid) .pfxcertificate(certificatepath, certificatepassword) .build(); secretclient secretclient = new secretclientbuilder() .vaulturl(keyvaulturl) .credential(clientcertificatecredential) .buildclient();
我已经尝试了相当多版本的依赖项,但仍然无法解决它,因为我是新手。现在已经坚持了几天了。依赖部分如下所示:
<!--<dependency> <groupid>com.azure</groupid> <artifactid>azure-core</artifactid> <version>1.26.0</version> </dependency>--> <dependency> <groupid>com.azure</groupid> <artifactid>azure-identity</artifactid> <version>1.7.0</version> </dependency> <dependency> <groupid>com.azure</groupid> <artifactid>azure-security-keyvault-secrets</artifactid> <version>4.2.3</version> </dependency> <!--<dependency> <groupid>com.fasterxml.jackson.core</groupid> <artifactid>jackson-core</artifactid> <version>2.14.0</version> </dependency>--> <dependency> <groupid>io.projectreactor</groupid> <artifactid>reactor-core</artifactid> <version>3.4.10</version> </dependency> <dependency> <groupid>io.projectreactor.netty</groupid> <artifactid>reactor-netty</artifactid> <version>1.0.11</version> </dependency>
我已经尝试过几个版本的依赖项,但我对此很陌生,无法弄清楚。
更新: 我在 pom 文件中添加了 azure bom,但错误仍然略有变化:
java.lang.NoClassDefFoundError: reactor/netty/transport/ClientTransport at com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:141) at com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:19) at com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:67) at com.azure.core.http.HttpClient.createDefault(HttpClient.java:50) at com.azure.core.http.HttpClient.createDefault(HttpClient.java:40) at com.azure.core.http.HttpPipelineBuilder.build(HttpPipelineBuilder.java:73) at com.azure.security.keyvault.secrets.SecretClientBuilder.buildAsyncClient(SecretClientBuilder.java:225) at com.azure.security.keyvault.secrets.SecretClientBuilder.buildClient(SecretClientBuilder.java:147) at com.snc.discovery.CredentialResolver.resolve(CredentialResolver.java:177) at com.service_now.mid.services.CredentialResolverProxy.resolveWithSemaphore(CredentialResolverProxy.java:392) at com.service_now.mid.services.CredentialResolverProxy.lambda$resolveFromVault$1(CredentialResolverProxy.java:329) at java.base/java.util.Optional.orElseGet(Optional.java:369) at com.service_now.mid.services.CredentialResolverProxy.resolveFromVault(CredentialResolverProxy.java:329) at com.service_now.mid.services.CredentialResolverProxy.lambda$resolve$0(CredentialResolverProxy.java:313) at java.base/java.util.Optional.orElseGet(Optional.java:369) at com.service_now.mid.services.CredentialResolverProxy.resolve(CredentialResolverProxy.java:313) at com.service_now.mid.creds.provider.standard.HighSecurityCredential.callResolver(HighSecurityCredential.java:55) at com.service_now.mid.creds.provider.standard.HighSecurityCredential.getAttribute(HighSecurityCredential.java:177) at com.snc.automation_common.integration.creds.Credential.isMidServerServiceAccount(Credential.java:151) at com.service_now.mid.win.powershell.api.APowershellSession.testCredential(APowershellSession.java:416) at com.service_now.mid.win.powershell.api.PowerShellConnectionFactory.getConnection(PowerShellConnectionFactory.java:60) at com.service_now.mid.win.powershell.api.PowerShellConnectionFactory.getConnection(PowerShellConnectionFactory.java:22) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnectionUseOneCred(AKeyedConnectionFactory.java:266) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnectionIterateOverCreds(AKeyedConnectionFactory.java:208) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:158) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:145) at com.snc.core_automation_common.util.AKeyedConnectionFactory.getConnection(AKeyedConnectionFactory.java:133) at com.service_now.mid.pipeline.command.TestCredentialCommandImpl.executeRawCommand(TestCredentialCommandImpl.java:126) at com.snc.core_automation_common.pipeline.ACommand.execute(ACommand.java:114) at com.service_now.mid.probe.CommandPipeline.probe(CommandPipeline.java:67) at com.service_now.mid.probe.AProbe.process(AProbe.java:155) at com.service_now.mid.queue_worker.AWorker.runWorker(AWorker.java:131) at com.service_now.mid.queue_worker.AWorkerThread.run(AWorkerThread.java:20) at com.service_now.mid.threadpool.ResourceUserQueue$RunnableProxy.run(ResourceUserQueue.java:640) at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) at java.base/java.lang.Thread.run(Thread.java:829)
我已经能够通过从 azure 依赖项(azure-identity 和 azure-security-keyvault-secrets)中排除 azure-core-http-netty
并添加 azure-core-http-okhttp
工件来解决该错误。
参考了这个帖子:
https://github.com/Azure/azure-sdk-for- java/issues/19041
以上是錯誤 java.lang.NoClassDefFoundError:reactor/netty/transport/ClientTransport的詳細內容。更多資訊請關注PHP中文網其他相關文章!