gpt4 book ai didi

spring - 带有环境变量的 azure-spring-apps-maven-plugin

转载 作者:行者123 更新时间:2023-12-03 01:59:40 25 4
gpt4 key购买 nike

我正在尝试使用 azure-spring-apps-maven-plugin (v1.19.0) 在 azure spring 应用程序上进行部署,以下是我的配置,但不知何故它没有更新 Azure Spring 应用程序中的环境变量。如果我从 Azure 门户手动设置环境变量,那么它可以工作,但不确定为什么它不能通过 maven 工作。

我已经尝试过以下配置

<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-apps-maven-plugin</artifactId>
<!--<version>1.17.0</version> -->
<version>1.19.0</version>
<configuration>
<subscriptionId>XXXXXXXXXX</subscriptionId>
<appName>demo</appName>
<resourceGroup>java-xxx-xxxx</resourceGroup>
<clusterName>spring-java-apps</clusterName>
<isPublic>true</isPublic>
<advancedOptions>true</advancedOptions>
<deployment>
<cpu>1</cpu>
<memoryInGB>2</memoryInGB>
<instanceCount>1</instanceCount>
<runtimeVersion>Java 17</runtimeVersion>
<environment> <SPRING_PROFILES_ACTIVE>dev</SPRING_PROFILES_ACTIVE>
</environment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>

最佳答案

but somehow it is not updating environment variables in Azure Spring app.

  • 使用 azure-spring-apps-maven-plugin 设置环境变量的正确方法是使用<property> <environment> 内的元素元素。不应该直接设置在 <environment> 里面作为子元素。这是更正后的配置。
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-spring-apps-maven-plugin</artifactId>
<version>1.19.0</version>
<configuration>
<subscriptionId>XXXXXXXXXX</subscriptionId>
<appName>demo</appName>
<resourceGroup>java-xxx-xxxx</resourceGroup>
<clusterName>spring-java-apps</clusterName>
<isPublic>true</isPublic>
<advancedOptions>true</advancedOptions>
<deployment>
<cpu>1</cpu>
<memoryInGB>2</memoryInGB>
<instanceCount>1</instanceCount>
<runtimeVersion>Java 17</runtimeVersion>
<environment>
<!-- Define your environment variables using <property> elements -->
<property>
<name>SPRING_PROFILES_ACTIVE</name>
<value>dev</value>
</property>
</environment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
  • 通过此更正的配置,SPRING_PROFILES_ACTIVE环境变量将设置为 dev在部署过程中使用azure-spring-apps-maven-plugin .

引用:

关于spring - 带有环境变量的 azure-spring-apps-maven-plugin,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/76800683/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com