java.lang.NoClassDefFoundError:使用azure ad时无法初始化类reactor.netty.http.client.HttpClientConfig

问题描述 投票:0回答:1

使用azure时出现以下异常。这是我的 pom.xml

<dependencies>
    <dependency>
        <groupId>com.microsoft.graph</groupId>
        <artifactId>microsoft-graph</artifactId>
        <version>5.53.0</version>
    </dependency>
    <dependency>
        <groupId>com.azure</groupId>
        <artifactId>azure-identity</artifactId>
        <version>1.8.2</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-api</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.logging.log4j</groupId>
        <artifactId>log4j-core</artifactId>
        <version>2.20.0</version>
    </dependency>
    <dependency>
        <groupId>org.apache.commons</groupId>
        <artifactId>commons-lang3</artifactId>
        <version>3.12.0</version>
    </dependency>
    <dependency>
        <groupId>commons-collections</groupId>
        <artifactId>commons-collections</artifactId>
        <version>3.2.2</version>
    </dependency>

这是我使用 ClientSecretCredentialBuilder 获取访问令牌的 java 代码

try {

        TokenRequestContext tokenRequestContext = new TokenRequestContext();
        AccessToken accessToken = new ClientSecretCredentialBuilder().clientId(clientId).clientSecret(clientSecret)
                .tenantId(tenantId).build().getTokenSync(tokenRequestContext.addScopes((".default")));
        

    } catch (Exception ex) {
        log.error("Azure Connection: FAILED ", ex);
    }

以下是我遇到的异常

java.lang.NoClassDefFoundError: Could not initialize class reactor.netty.http.client.HttpClientConfig
reactor.netty.http.client.HttpClientConnect.<init>(HttpClientConnect.java:84)
reactor.netty.http.client.HttpClient.create(HttpClient.java:398)
com.azure.core.http.netty.NettyAsyncHttpClientBuilder.build(NettyAsyncHttpClientBuilder.java:145)
com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:56)
com.azure.core.http.netty.NettyAsyncHttpClientProvider.createInstance(NettyAsyncHttpClientProvider.java:62)
com.azure.core.implementation.http.HttpClientProviders.lambda$createInstance$0(HttpClientProviders.java:46)
com.azure.core.implementation.util.Providers.create(Providers.java:109)
com.azure.core.implementation.http.HttpClientProviders.createInstance(HttpClientProviders.java:46)
com.azure.core.http.HttpClient.createDefault(HttpClient.java:61)
com.azure.core.http.HttpClient.createDefault(HttpClient.java:51)
com.azure.identity.implementation.IdentityClientBase.initializeHttpPipelineAdapter(IdentityClientBase.java:574)
com.azure.identity.implementation.IdentityClientBase.getConfidentialClient(IdentityClientBase.java:216)
com.azure.identity.implementation.IdentitySyncClient.lambda$new$1(IdentitySyncClient.java:77)
com.azure.identity.implementation.SynchronousAccessor.getValue(SynchronousAccessor.java:45)
com.azure.identity.implementation.IdentitySyncClient.authenticateWithConfidentialClientCache(IdentitySyncClient.java:141)
com.azure.identity.ClientSecretCredential.getTokenSync(ClientSecretCredential.java:88)
com.services.azure.service.TestAzureConnection.Test(TestAzureConnection.java:75)

我的 pom.xml 中的上述配置已经存在一年了,我没有遇到任何异常,突然我开始遇到此异常。这是否与 azure 或导致此问题的任何其他依赖项有关。

这是我的 mvn 依赖项:树

[INFO] +- com.microsoft.sqlserver:mssql-jdbc:jar:12.2.0.jre8:compile
[INFO] +- com.github.ziplet:ziplet:jar:2.4.1:compile
[INFO] |  \- org.slf4j:slf4j-api:jar:1.7.6:compile
[INFO] +- javax.ws.rs:jsr311-api:jar:1.1.1:compile
[INFO] +- com.sun.jersey:jersey-bundle:jar:1.19.4:compile
[INFO] +- mysql:mysql-connector-java:jar:8.0.23:compile
[INFO] |  \- com.google.protobuf:protobuf-java:jar:3.11.4:compile
[INFO] +- javax.servlet:javax.servlet-api:jar:3.1.0:compile
[INFO] +- org.junit.jupiter:junit-jupiter-engine:jar:5.5.2:test
[INFO] |  +- org.apiguardian:apiguardian-api:jar:1.1.0:test
[INFO] |  +- org.junit.platform:junit-platform-engine:jar:1.5.2:test
[INFO] |  |  +- org.opentest4j:opentest4j:jar:1.2.0:test
[INFO] |  |  \- org.junit.platform:junit-platform-commons:jar:1.5.2:test
[INFO] |  \- org.junit.jupiter:junit-jupiter-api:jar:5.5.2:test
[INFO] +- org.junit.platform:junit-platform-runner:jar:1.5.2:test
[INFO] |  +- org.junit.platform:junit-platform-launcher:jar:1.5.2:test
[INFO] |  \- org.junit.platform:junit-platform-suite-api:jar:1.5.2:test
[INFO] +- org.glassfish.web:jstl-impl:jar:1.2:compile
[INFO] |  +- javax.servlet:servlet-api:jar:2.5:compile
[INFO] |  +- javax.servlet.jsp:jsp-api:jar:2.1:compile
[INFO] |  \- javax.servlet.jsp.jstl:jstl-api:jar:1.2:compile
[INFO] +- org.hibernate:hibernate-core:jar:4.1.4.Final:compile
[INFO] |  +- antlr:antlr:jar:2.7.7:compile
[INFO] |  +- org.jboss.logging:jboss-logging:jar:3.1.0.GA:compile
[INFO] |  +- org.jboss.spec.javax.transaction:jboss-transaction-api_1.1_spec:jar:1.0.0.Final:compile
[INFO] |  +- dom4j:dom4j:jar:1.6.1:compile
[INFO] |  +- org.hibernate.javax.persistence:hibernate-jpa-2.0-api:jar:1.0.1.Final:compile
[INFO] |  +- org.javassist:javassist:jar:3.15.0-GA:compile
[INFO] |  \- org.hibernate.common:hibernate-commons-annotations:jar:4.0.1.Final:compile
[INFO] +- org.hibernate:hibernate-ehcache:jar:4.1.4.Final:compile
[INFO] |  \- net.sf.ehcache:ehcache-core:jar:2.4.3:compile
[INFO] +- org.codehaus.jackson:jackson-core-asl:jar:1.9.13:compile
[INFO] +- javax.xml.bind:jaxb-api:jar:2.2.7:compile
[INFO] +- com.sun.jersey.contribs:jersey-multipart:jar:1.19.4:compile
[INFO] |  \- org.jvnet.mimepull:mimepull:jar:1.9.3:compile
[INFO] +- org.codehaus.jettison:jettison:jar:1.1:compile
[INFO] |  \- stax:stax-api:jar:1.0.1:compile
[INFO] +- com.sun.mail:javax.mail:jar:1.6.2:compile
[INFO] |  \- javax.activation:activation:jar:1.1:compile
[INFO] +- org.jasypt:jasypt:jar:1.9.2:compile
[INFO] +- com.google.code.gson:gson:jar:2.5:compile
[INFO] +- com.mycompnayname.service:sapjco3:jar:2.0.0:compile
[INFO] +- com.dropbox.core:dropbox-core-sdk:jar:1.7.7:compile
[INFO] +- com.fasterxml.jackson.core:jackson-databind:jar:2.14.1:compile
[INFO] |  \- com.fasterxml.jackson.core:jackson-core:jar:2.14.1:compile
[INFO] +- com.fasterxml.jackson.core:jackson-annotations:jar:2.14.1:compile
[INFO] +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:jar:2.14.1:compile
[INFO] |  +- com.fasterxml.jackson.jaxrs:jackson-jaxrs-base:jar:2.14.1:compile
[INFO] |  \- com.fasterxml.jackson.module:jackson-module-jaxb-annotations:jar:2.14.1:compile
[INFO] |     +- jakarta.xml.bind:jakarta.xml.bind-api:jar:2.3.3:compile
[INFO] |     \- jakarta.activation:jakarta.activation-api:jar:1.2.2:compile
[INFO] +- org.apache.poi:poi:jar:3.14:compile
[INFO] |  \- commons-codec:commons-codec:jar:1.10:compile
[INFO] +- org.apache.poi:poi-ooxml:jar:3.14:compile
[INFO] |  +- org.apache.poi:poi-ooxml-schemas:jar:3.14:compile
[INFO] |  |  \- org.apache.xmlbeans:xmlbeans:jar:2.6.0:compile
[INFO] |  \- com.github.virtuald:curvesapi:jar:1.03:compile
[INFO] +- commons-httpclient:commons-httpclient:jar:3.0.1:compile
[INFO] |  \- commons-logging:commons-logging:jar:1.0.3:compile
[INFO] +- com.googlecode.json-simple:json-simple:jar:1.1.1:compile
[INFO] +- org.springframework:spring-core:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-context:jar:4.3.5.RELEASE:compile
[INFO] |  +- org.springframework:spring-beans:jar:4.3.5.RELEASE:compile
[INFO] |  \- org.springframework:spring-expression:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-web:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-webmvc:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-aop:jar:4.3.5.RELEASE:compile
[INFO] +- org.springframework:spring-test:jar:4.3.5.RELEASE:compile
[INFO] +- com.sun.jersey.contribs:jersey-spring:jar:1.19.4:compile
[INFO] +- org.springframework.security:spring-security-web:jar:4.2.1.RELEASE:compile
[INFO] |  +- aopalliance:aopalliance:jar:1.0:compile
[INFO] |  \- org.springframework.security:spring-security-core:jar:4.2.1.RELEASE:compile
[INFO] +- org.springframework.security:spring-security-config:jar:4.2.1.RELEASE:compile
[INFO] +- org.springframework.security.extensions:spring-security-saml2-core:jar:1.0.2.RELEASE:compile
[INFO] |  +- org.opensaml:opensaml:jar:2.6.1:compile
[INFO] |  |  +- org.opensaml:openws:jar:1.5.1:compile
[INFO] |  |  |  +- org.opensaml:xmltooling:jar:1.4.1:compile
[INFO] |  |  |  |  +- org.bouncycastle:bcprov-jdk15:jar:1.46:compile
[INFO] |  |  |  |  \- ca.juliusdavies:not-yet-commons-ssl:jar:0.3.9:compile
[INFO] |  |  |  \- org.apache.santuario:xmlsec:jar:1.5.6:compile
[INFO] |  |  +- org.apache.velocity:velocity:jar:1.7:compile
[INFO] |  |  +- org.owasp.esapi:esapi:jar:2.0.1:compile
[INFO] |  |  +- joda-time:joda-time:jar:2.2:compile
[INFO] |  |  +- xerces:xercesImpl:jar:2.10.0:runtime
[INFO] |  |  +- xalan:serializer:jar:2.7.1:runtime
[INFO] |  |  +- xml-resolver:xml-resolver:jar:1.2:runtime
[INFO] |  |  \- xalan:xalan:jar:2.7.1:runtime
[INFO] |  \- xml-apis:xml-apis:jar:1.4.01:runtime
[INFO] +- commons-fileupload:commons-fileupload:jar:1.2.2:compile
[INFO] +- org.apache.logging.log4j:log4j-api:jar:2.18.0:compile
[INFO] +- org.apache.logging.log4j:log4j-core:jar:2.18.0:compile
[INFO] +- com.opencsv:opencsv:jar:4.5:compile
[INFO] |  +- org.apache.commons:commons-text:jar:1.3:compile
[INFO] |  +- commons-beanutils:commons-beanutils:jar:1.9.3:compile
[INFO] |  \- org.apache.commons:commons-collections4:jar:4.2:compile
[INFO] +- junit:junit:jar:3.8.1:test
[INFO] +- org.json:json:jar:20190722:compile
[INFO] +- net.sf.opencsv:opencsv:jar:2.3:compile
[INFO] +- com.relevantcodes:extentreports:jar:2.41.1:compile
[INFO] |  +- org.jsoup:jsoup:jar:1.8.3:compile
[INFO] |  +- org.xerial:sqlite-jdbc:jar:3.8.11.1:compile
[INFO] |  +- org.freemarker:freemarker:jar:2.3.23:compile
[INFO] |  \- org.mongodb:mongodb-driver:jar:3.0.4:compile
[INFO] |     \- org.mongodb:mongodb-driver-core:jar:3.0.4:compile
[INFO] +- commons-io:commons-io:jar:1.3.2:compile
[INFO] +- org.seleniumhq.selenium:selenium-java:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-api:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-chrome-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-edge-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-firefox-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-ie-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-opera-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-remote-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-safari-driver:jar:3.6.0:compile
[INFO] |  +- org.seleniumhq.selenium:selenium-support:jar:3.6.0:compile
[INFO] |  +- net.bytebuddy:byte-buddy:jar:1.7.5:compile
[INFO] |  +- org.apache.commons:commons-exec:jar:1.3:compile
[INFO] |  +- org.apache.httpcomponents:httpclient:jar:4.5.3:compile
[INFO] |  +- org.apache.httpcomponents:httpcore:jar:4.4.6:compile
[INFO] |  +- net.java.dev.jna:jna:jar:4.1.0:compile
[INFO] |  \- net.java.dev.jna:jna-platform:jar:4.1.0:compile
[INFO] +- org.testng:testng:jar:6.10:compile
[INFO] |  \- com.beust:jcommander:jar:1.48:compile
[INFO] +- com.google.guava:guava:jar:27.1-jre:compile
[INFO] |  +- com.google.guava:failureaccess:jar:1.0.1:compile
[INFO] |  +- com.google.guava:listenablefuture:jar:9999.0-empty-to-avoid-conflict-with-guava:compile
[INFO] |  +- com.google.code.findbugs:jsr305:jar:3.0.2:compile
[INFO] |  +- org.checkerframework:checker-qual:jar:2.5.2:compile
[INFO] |  +- com.google.errorprone:error_prone_annotations:jar:2.2.0:compile
[INFO] |  +- com.google.j2objc:j2objc-annotations:jar:1.1:compile
[INFO] |  \- org.codehaus.mojo:animal-sniffer-annotations:jar:1.17:compile
[INFO] +- org.quartz-scheduler:quartz:jar:2.2.1:compile
[INFO] +- org.quartz-scheduler:quartz-jobs:jar:2.2.1:compile
[INFO] +- org.apache.commons:commons-lang3:jar:3.12.0:compile
[INFO] +- commons-lang:commons-lang:jar:2.6:compile
[INFO] +- com.sun.jersey:jersey-json:jar:1.19.4:compile
[INFO] |  +- com.sun.xml.bind:jaxb-impl:jar:2.2.3-1:compile
[INFO] |  +- org.codehaus.jackson:jackson-mapper-asl:jar:1.9.2:compile
[INFO] |  +- org.codehaus.jackson:jackson-jaxrs:jar:1.9.2:compile
[INFO] |  \- org.codehaus.jackson:jackson-xc:jar:1.9.2:compile
[INFO] +- com.sun.jersey:jersey-server:jar:1.19.4:compile
[INFO] +- com.sun.jersey:jersey-core:jar:1.19.4:compile
[INFO] +- com.sun.jersey:jersey-servlet:jar:1.19.4:compile
[INFO] +- javax.websocket:javax.websocket-api:jar:1.1:provided
[INFO] +- io.rest-assured:rest-assured:jar:4.3.0:provided
[INFO] |  +- org.codehaus.groovy:groovy:jar:3.0.2:provided
[INFO] |  +- org.codehaus.groovy:groovy-xml:jar:3.0.2:provided
[INFO] |  +- org.apache.httpcomponents:httpmime:jar:4.5.3:provided
[INFO] |  +- org.hamcrest:hamcrest:jar:2.1:provided
[INFO] |  +- org.ccil.cowan.tagsoup:tagsoup:jar:1.2.1:provided
[INFO] |  \- io.rest-assured:xml-path:jar:4.3.0:provided
[INFO] |     +- com.sun.xml.bind:jaxb-osgi:jar:2.3.0.1:provided
[INFO] |     \- org.apache.sling:org.apache.sling.javax.activation:jar:0.1.0:provided
[INFO] +- io.rest-assured:json-path:jar:4.3.0:provided
[INFO] |  +- org.codehaus.groovy:groovy-json:jar:3.0.2:provided
[INFO] |  \- io.rest-assured:rest-assured-common:jar:4.3.0:provided
[INFO] +- com.aventstack:extentreports:jar:4.0.6:provided
[INFO] |  \- org.mongodb:bson:jar:3.3.0:compile
[INFO] +- org.dhatim:fastexcel:jar:0.12.8:compile
[INFO] |  \- com.github.rzymek:opczip:jar:1.0.2:compile
[INFO] +- org.dhatim:fastexcel-reader:jar:0.12.3:compile
[INFO] |  +- com.fasterxml:aalto-xml:jar:1.2.2:compile
[INFO] |  |  \- org.codehaus.woodstox:stax2-api:jar:4.2:compile
[INFO] |  \- org.apache.commons:commons-compress:jar:1.20:compile
[INFO] +- software.aws.rds:aws-mysql-jdbc:jar:1.1.5:compile
[INFO] +- com.mycompanyname:authorization:jar:1.0.5:compile
[INFO] |  +- com.microsoft.graph:microsoft-graph:jar:5.53.0:compile
[INFO] |  |  +- com.microsoft.graph:microsoft-graph-core:jar:2.0.17:compile
[INFO] |  |  |  \- com.github.spotbugs:spotbugs-annotations:jar:4.7.3:compile
[INFO] |  |  \- com.squareup.okhttp3:okhttp:jar:4.10.0:compile
[INFO] |  |     +- com.squareup.okio:okio-jvm:jar:3.0.0:compile
[INFO] |  |     |  +- org.jetbrains.kotlin:kotlin-stdlib-jdk8:jar:1.5.31:compile
[INFO] |  |     |  |  \- org.jetbrains.kotlin:kotlin-stdlib-jdk7:jar:1.5.31:compile
[INFO] |  |     |  \- org.jetbrains.kotlin:kotlin-stdlib-common:jar:1.5.31:compile
[INFO] |  |     \- org.jetbrains.kotlin:kotlin-stdlib:jar:1.6.20:compile
[INFO] |  |        \- org.jetbrains:annotations:jar:13.0:compile
[INFO] |  +- com.azure:azure-identity:jar:1.8.2:compile
[INFO] |  |  +- com.azure:azure-core:jar:1.38.0:compile
[INFO] |  |  |  +- com.azure:azure-json:jar:1.0.0:compile
[INFO] |  |  |  +- com.fasterxml.jackson.datatype:jackson-datatype-jsr310:jar:2.13.5:compile
[INFO] |  |  |  \- io.projectreactor:reactor-core:jar:3.4.27:compile
[INFO] |  |  |     \- org.reactivestreams:reactive-streams:jar:1.0.4:compile
[INFO] |  |  +- com.azure:azure-core-http-netty:jar:1.13.2:compile
[INFO] |  |  |  +- io.netty:netty-handler:jar:4.1.89.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-common:jar:4.1.89.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-resolver:jar:4.1.89.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-transport:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-handler-proxy:jar:4.1.89.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-codec-socks:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-buffer:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-codec:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-codec-http:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-codec-http2:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport-native-unix-common:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport-native-epoll:jar:linux-x86_64:4.1.89.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-transport-classes-epoll:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-transport-native-kqueue:jar:osx-x86_64:4.1.89.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-transport-classes-kqueue:jar:4.1.89.Final:compile
[INFO] |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:2.0.56.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-tcnative-classes:jar:2.0.56.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:linux-x86_64:2.0.56.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:linux-aarch_64:2.0.56.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:osx-x86_64:2.0.56.Final:compile
[INFO] |  |  |  |  +- io.netty:netty-tcnative-boringssl-static:jar:osx-aarch_64:2.0.56.Final:compile
[INFO] |  |  |  |  \- io.netty:netty-tcnative-boringssl-static:jar:windows-x86_64:2.0.56.Final:compile
[INFO] |  |  |  \- io.projectreactor.netty:reactor-netty-http:jar:1.0.28:compile
[INFO] |  |  |     +- io.netty:netty-resolver-dns:jar:4.1.89.Final:compile
[INFO] |  |  |     |  \- io.netty:netty-codec-dns:jar:4.1.89.Final:compile
[INFO] |  |  |     +- io.netty:netty-resolver-dns-native-macos:jar:osx-x86_64:4.1.89.Final:compile
[INFO] |  |  |     |  \- io.netty:netty-resolver-dns-classes-macos:jar:4.1.89.Final:compile
[INFO] |  |  |     \- io.projectreactor.netty:reactor-netty-core:jar:1.0.28:compile
[INFO] |  |  +- com.microsoft.azure:msal4j:jar:1.13.7:compile
[INFO] |  |  |  \- com.nimbusds:oauth2-oidc-sdk:jar:9.35:compile
[INFO] |  |  |     +- com.github.stephenc.jcip:jcip-annotations:jar:1.0-1:compile
[INFO] |  |  |     +- com.nimbusds:content-type:jar:2.2:compile
[INFO] |  |  |     +- net.minidev:json-smart:jar:2.4.8:compile
[INFO] |  |  |     |  \- net.minidev:accessors-smart:jar:2.4.8:compile
[INFO] |  |  |     |     \- org.ow2.asm:asm:jar:9.1:compile
[INFO] |  |  |     +- com.nimbusds:lang-tag:jar:1.6:compile
[INFO] |  |  |     \- com.nimbusds:nimbus-jose-jwt:jar:9.22:compile
[INFO] |  |  \- com.microsoft.azure:msal4j-persistence-extension:jar:1.1.0:compile
[INFO] |  \- commons-collections:commons-collections:jar:3.2.2:compile
[INFO] \- io.jsonwebtoken:jjwt:jar:0.9.1:compile

任何帮助/建议

java azure azure-active-directory azure-sdk azure-sdk-for-java
1个回答
0
投票

要解决此错误,您必须在

reactor-core
中添加
POM.XML
依赖项。

<dependency>
    <groupId>io.projectreactor</groupId>
    <artifactId>reactor-core</artifactId>
    <version>3.6.9</version>
</dependency>

或在您的应用程序中使用以下

pom.xml

<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.7.8</version>
        <relativePath /> 
    </parent>
    <groupId>com.myapp</groupId>
    <artifactId>restcall</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>restcall</name>
    <description>Demo project for Spring Boot</description>
    <properties>
        <java.version>11</java.version>
    </properties>
    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
        </dependency>
        <dependency>
            <groupId>com.squareup.okhttp</groupId>
            <artifactId>okhttp</artifactId>
            <version>2.7.5</version>
        </dependency>
        <dependency>
            <groupId>org.json</groupId>
            <artifactId>json</artifactId>
            <version>20220924</version>
        </dependency>
            <dependency>
                <groupId>com.microsoft.graph</groupId>
                <artifactId>microsoft-graph</artifactId>
                <version>5.53.0</version>
            </dependency>
            <dependency>
                <groupId>com.azure</groupId>
                <artifactId>azure-identity</artifactId>
                <version>1.8.2</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-api</artifactId>
                <version>2.20.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.logging.log4j</groupId>
                <artifactId>log4j-core</artifactId>
                <version>2.20.0</version>
            </dependency>
            <dependency>
                <groupId>org.apache.commons</groupId>
                <artifactId>commons-lang3</artifactId>
                <version>3.12.0</version>
            </dependency>
            <dependency>
                <groupId>commons-collections</groupId>
                <artifactId>commons-collections</artifactId>
                <version>3.2.2</version>
            </dependency>
            <dependency>
                <groupId>com.microsoft.azure</groupId>
                <artifactId>msal4j</artifactId>
                <version>1.16.2</version>
            </dependency>
    </dependencies>
    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>
</project>

代码片段:

    TokenRequestContext tokenRequestContext = new TokenRequestContext();
    AccessToken accessToken = new ClientSecretCredentialBuilder().clientId("Client_ID").clientSecret("Client_Secret")
            .tenantId("Tenant_ID").build().getTokenSync(tokenRequestContext.addScopes((".default")));
            System.out.println(accessToken.getToken());
            return accessToken.getToken();

回复:

enter image description here

enter image description here

最新问题
© www.soinside.com 2019 - 2024. All rights reserved.