java - 使用 Maven 部署 Azure Spring 应用程序会导致错误 : Invalid arguments: DeploymentSettings must be provided

标签 java spring-boot azure maven azure-spring-cloud

我正在尝试使用 Maven 将 Spring Boot 应用程序部署到 Microsoft Azure Spring Apps。

我严格遵循了 Microsoft 的本教程:https://learn.microsoft.com/en-us/azure/spring-apps/how-to-maven-deploy-apps ,除了 azure-spring-apps-maven-plugin 必须从 1.10.0 升级到 1.17.0,如下所示:

mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config

但是当使用示例项目运行部署命令时:

mvn azure-spring-apps:部署

出现以下“无效参数:必须提供 DeploymentSettings” 错误:

[ERROR] Operator called default onErrorDropped
reactor.core.Exceptions$StaticThrowable: Operator has been terminated
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  13.680 s
[INFO] Finished at: 2023-05-02T19:06:23+02:00
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:deploy (default-cli) on project hellospring: create or update Spring app(hellospring) from config: AzureToolkitRuntimeException: create Azure Spring App deployment (default): Status code 400, "{"error":{"code":"BadArgument","message":"Invalid arguments: DeploymentSettings must be provided.","details":[{"code":"BadArgument","message":"DeploymentSettings must be provided.","target":"Properties.DeploymentSettings"}]}}" -> [Help 1]

HelloSpring 示例应用程序不需要任何特定配置(无数据库、无文件存储、无 https 证书等)。

知道我可能做错了什么吗?

最佳答案

Azure Spring Apps deployment with Maven causes error : Invalid arguments: DeploymentSettings must be provided

我建议您在将应用程序部署到 Azure Spring Apps 之前运行 mvn clean install

并在运行mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config后检查以下配置是否添加到您的pom.xml文件中.

<plugin>
        <groupId>com.microsoft.azure</groupId>
        <artifactId>azure-spring-apps-maven-plugin</artifactId>
        <version>1.17.0</version>
        <configuration>
                    
            <subscriptionId>Azure_SUbscription_id</subscriptionId>
            <resourceGroup>Resource_group_name</resourceGroup>
            <clusterName>kpspringapp</clusterName>
            <appName>springboot-crud</appName>
            <isPublic>false</isPublic>
            <deployment>
                  <cpu>1</cpu>
                  <memoryInGB>1</memoryInGB>
                  <instanceCount>1</instanceCount>
                  <runtimeVersion>Java 11</runtimeVersion>
                  <resources>
                      <resource>
                          <filtering/>
                          <mergeId/>
                          <targetPath/>
                        <directory>${project.basedir}/target</directory>
                          <includes>
                               <include>*.jar</include>
                          </includes>
                       </resource>
                   </resources>
              </deployment>
         </configuration>
    </plugin>

我创建了一个 Spring Boot 应用程序并部署到 Azure Spring Apps:

  1. 通过命令行登录 Azure。

enter image description here

  • 通过运行 mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config 命令生成配置以将 Spring Boot 应用程序部署到 Azure Spring Apps。 这将要求选择订阅、资源组、Azure Spring 应用程序名称、Java 运行时版本等,然后生成部署所需的配置。
  • enter image description here enter image description here

    我最初也遇到错误,无法部署应用程序。 但是,运行命令 mvn clean install 后,我能够将应用程序部署到 Spring 应用程序。

    enter image description here enter image description here enter image description here

    将应用程序部署到 Azure Spring Apps:

    enter image description here

    门户: enter image description here

    回应: enter image description here

    关于java - 使用 Maven 部署 Azure Spring 应用程序会导致错误 : Invalid arguments: DeploymentSettings must be provided,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76157424/

    相关文章:

    Java : Cannot send POST request to backend with Angular 5

    适用于 Azure blob 的 Python requests.get()

    javascript - Azure Functions 中通过整数 SQL 查询 DocumentDB 不起作用

    java - 如何在 Spring Boot 中进行多个 URL 映射(别名)

    java - maven-bundle-plugin 中具有相同名称的多个引用

    java - 对线程安全的质疑

    java - 多次从 ArrayList 追加会导致同时打印多个值吗?

    bash - 如何检查docker Cassandra实例是否准备好进行连接

    Azure Function cosmosDB 触发器托管标识不起作用

    java - Eclipse 系统.属性 Windows 7