尝试连接 azure AuthenticationResult,但收到错误 java.lang.NoClassDefFo



尝试通过休息服务调用与 azure 身份验证结果连接,但收到错误消息

{ "代码":500, "message": "java.lang.NoClassDefFoundError: com/nimbusds/jwt/JWTParser" }

private static AuthenticationResult getAccessTokenFromUserCredentials(String username, String password)
throws Exception {
AuthenticationContext context;
AuthenticationResult result;
ExecutorService service = null;
try {
service = Executors.newFixedThreadPool(1);
context = new AuthenticationContext(AUTHORITY, false, service);
Future<AuthenticationResult> future = context.acquireToken("https://graph.microsoft.com", CLIENT_ID, username, password, null);
result = future.get();
} finally {
service.shutdown();
}
if (result == null) {
throw new ServiceUnavailableException("authentication result was null");
}
return result;
}

我也有类似的错误。这是由于运行时依赖类 un 可用性。尝试添加此nimbus-jose-jwt JAR 版本 4.2

链接 https://jar-download.com/artifacts/com.nimbusds/nimbus-jose-jwt/4.2/source-code

找出此错误的方法是,使用您的类名 com.nimbusds.jwt.JWTParser jar 进行搜索,在添加之前,您必须在 jar 中找到该类。试试看,告诉我们。

您是否将 ADAL 库添加到构建文件 (pom.xml 或 build.gradle)?无论如何,请查找以下依赖项:

<!-- https://mvnrepository.com/artifact/com.nimbusds/nimbus-jose-jwt -->
<dependency>
<groupId>com.nimbusds</groupId>
<artifactId>nimbus-jose-jwt</artifactId>
<version>2.15.1</version>
</dependency>

相关内容

最新更新