com.azure.cosmos.CosmosException(与输入授权令牌相关)更新 Spring Boot 版本和 Azure Cosmos DB 版本后

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

我需要更新当前项目中的 Spring Boot 版本和 Azure Cosmos DB 版本。下面是它们在 pom.xml 文件中的样子,应用程序可以毫无问题地运行。

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>2.3.4.RELEASE</version>
        <relativePath /> <!-- lookup parent from repository -->
    </parent>
        <dependency>
            <groupId>com.azure</groupId>
            <artifactId>azure-spring-data-cosmos</artifactId>
            <version>3.4.0</version>
        </dependency>

但是,当我将Springboot版本更新到2.5.12(或2.7.2),将cosmosCosmos DB版本更新到3.19.0(或3.33.0以及Springboot 2.7.2版本)后,我可以成功构建并安装mvn包,但是当我开始运行这个项目时,我得到了下面两个与 Cosmos 相关的异常。

com.azure.cosmos.CosmosException: {"innerErrorMessage":"The input authorization token can't serve the request. The wrong key is being used or the expected payload is not built as per the protocol. For more info: https://aka.ms/cosmosdb-tsg-unauthorized. Server used the following payload to sign: ...

java.lang.RuntimeException: Client initialization failed. Check if the endpoint is reachable and if your auth token is valid. More info: https://aka.ms/cosmosdb-tsg-service-unavailable-java

为了信息的完整性,我将 application.yml 文件中的“profiles”属性更新为“config.active.on-profile”,因为控制台中有一个“WARN”行,指出“Property 'spring.profiles' imported from [ application.yml]'无效,当我开始使用较新版本的Springboot和Cosmos运行应用程序时,应替换为'spring.config.active.on-profile'”;为了确保我所有的配置属性都正常工作,我使用带有此类更新的 application.yml 文件与 Springboot2.5.12+CosmosDB3.14.0 和 Springboot2.7.2+CosmosDB3.33.0.

一起运行

我试过以下方法:

spring-boot azure-cosmosdb pom.xml maven-dependency maven-package
© www.soinside.com 2019 - 2024. All rights reserved.