java - Java 应用始终部署为 Azure 上的新应用服务
问题描述
我正在尝试通过 Azure Shell 部署 .jar SpringBoot 应用程序。我已经(通过站点)创建了应用服务计划和应用服务,所以在 pom 配置中我提到了现有服务的名称。所以当我试图运行mvn azure-webapp:deploy
它总是失败
“同名的服务已经存在”
有没有办法在不创建新 AppService 的情况下强制使用现有 AppService?因为现在看起来它会尝试在我所做的每一次更新中进行创建。
更新:我的工作插件设置
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
<schemaVersion>V2</schemaVersion>
<resourceGroup>___</resourceGroup>
<appName>___</appName>
<appServicePlanName>___</appServicePlanName>
<pricingTier>F1</pricingTier>
<region>eastus</region>
<runtime>
<os>windows</os>
<javaVersion>11</javaVersion>
<webContainer>java 11</webContainer>
</runtime>
<!-- Begin of App Settings -->
<appSettings>
<property>
<name>JAVA_OPTS</name>
<value>-Dserver.port=80 -Djava.net.preferIPv4Stack=true</value>
</property>
</appSettings>
<!-- End of App Settings -->
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
解决方案
Java Jdk 版本是问题所在。
我有一个现有的 azure app 服务,一个空的 spring boot 应用程序在本地运行良好,从这里下载:git clone https://github.com/spring-guides/gs-spring-boot
这是部署到现有应用程序服务的pom.xml对我来说效果很好。
<?xml version="1.0" encoding="UTF-8"?>
<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.3.3.RELEASE</version>
<relativePath/>
<!-- lookup parent from repository -->
</parent>
<groupId>com.example</groupId>
<artifactId>spring-boot</artifactId>
<version>0.0.1-SNAPSHOT</version>
<name>spring-boot</name>
<description>Demo project for Spring Boot</description>
<properties>
<java.version>1.8</java.version>
</properties>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<!-- tag::actuator[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-actuator</artifactId>
</dependency>
<!-- end::actuator[] -->
<!-- tag::tests[] -->
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-test</artifactId>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.junit.vintage</groupId>
<artifactId>junit-vintage-engine</artifactId>
</exclusion>
</exclusions>
</dependency>
<!-- end::tests[] -->
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
</plugin>
<plugin>
<groupId>com.microsoft.azure</groupId>
<artifactId>azure-webapp-maven-plugin</artifactId>
<version>1.12.0</version>
<configuration>
<schemaVersion>v2</schemaVersion>
<subscriptionId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</subscriptionId>
<resourceGroup>MyRG</resourceGroup>
<appName>dorisspring</appName>
<pricingTier>B1</pricingTier>
<region>centralus</region>
<runtime>
<os>Windows</os>
<javaVersion>Java 8</javaVersion>
<webContainer>Java SE</webContainer>
</runtime>
<deployment>
<resources>
<resource>
<directory>${project.basedir}/target</directory>
<includes>
<include>*.jar</include>
</includes>
</resource>
</resources>
</deployment>
</configuration>
</plugin>
</plugins>
</build>
</project>
这是我的命令:
mvn spring-boot:run
mvn clean install #check the "target" folder including jdk created by this command
mvn azure-webapp:config
mvn azure-webapp:deploy
部署成功:
提示:确保java版本匹配。
推荐阅读
- ios - 带有顺序和限制的 Firestore 复合查询
- vim - 不同语言和任务的不同vim文件
- python-3.x - 在由字典组成的数据集上,如何将每个字典的元素与 Python 相乘'
- swiftui - 为什么嵌入到 SwiftUI 表单中的按钮不起作用?
- c - 如何在没有 strlen()、sizeof(arr) / sizeof(arr[0]) 的情况下获取这个数组的长度;不行,C语言
- python - TypeError:“模块”对象在使用 selenium webdriver 打开 chrome 浏览器时不可调用
- javascript - Eslint:警告文件默认被忽略。使用否定忽略模式
- java - 设置 Autocompleteplace setupAutocompleteTextView
- checkbox - 如果在 Google 表格中选中复选框,则有条件地格式化具有匹配文本的单元格
- android - 在 EditText 中从 Firebase 检索和显示数据并编辑内容并再次保存