java应用程序始终部署为azure上的新应用程序服务

zmeyuzjn  于 2021-07-08  发布在  Java
关注(0)|答案(2)|浏览(419)

我正在尝试通过azure shell部署.jar springboot应用程序。我已经创建了(通过网站)应用服务计划和应用服务,所以在pom配置我提到现有服务的名称。所以当我想跑的时候 mvn azure-webapp:deploy 它总是以失败告终
“具有此名称的服务已存在”
有没有办法强制使用现有的appservice而不创建新的appservice?因为现在它看起来像是要尝试用我做的每一个更新来创建。
upd:我的工作插件设置

<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>
xv8emn3q

xv8emn3q1#

我的设置(请参阅插件配置的编辑问题)的最终效果是使用最新版本的azure插件(1.12.0)。看来问题已经解决了。否则,请尝试使用较旧的版本(例如,1.6.0版适用于我,请参阅下面的评论)

4xrmg8kj

4xrmg8kj2#

javajdk版本就是问题所在。
我有一个exist azure应用程序服务,一个空的spring启动应用程序在本地运行良好,可以从这里下载: git clone https://github.com/spring-guides/gs-spring-boot
以下是pom.xml部署到exist应用程序服务在我这边运行良好。

<?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版本匹配。

相关问题