我正在尝试使用 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:
- 通过命令行登录 Azure。
- 通过运行
mvn com.microsoft.azure:azure-spring-apps-maven-plugin:1.17.0:config
命令生成配置以将 Spring Boot 应用程序部署到 Azure Spring Apps。 这将要求选择订阅、资源组、Azure Spring 应用程序名称、Java 运行时版本等,然后生成部署所需的配置。
我最初也遇到错误,无法部署应用程序。
但是,运行命令 mvn clean install
后,我能够将应用程序部署到 Spring 应用程序。
将应用程序部署到 Azure Spring Apps:
门户:
回应:
关于java - 使用 Maven 部署 Azure Spring 应用程序会导致错误 : Invalid arguments: DeploymentSettings must be provided,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76157424/