在Google AppEngine +非零退出2中部署Spring Boot应用程序时出错

时间:2019-03-31 21:14:22

标签: spring-boot google-app-engine google-cloud-platform

在GAE中部署测试Maven Spring Boot REST应用时,我遇到了以下错误-

[错误]无法在项目PublicLibrary上执行目标com.google.cloud.tools:appengine-maven-plugin:2.0.0-rc5:deploy(default-cli):App Engine应用程序部署失败:com .google.cloud.tools.appengine.operations.cloudsdk.process.ProcessHandlerException:com.google.cloud.tools.appengine.AppEngineException:非零退出:2-> [帮助1]

App.yaml看起来像

runtime: java
env: flex
runtime_config:
  jdk: openjdk8
env_variables:
  SPRING_PROFILES_ACTIVE: "gcp"
handlers:
- url: /.*
  script: this field is required, but ignored
manual_scaling: 
  instances: 1

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 http://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.1.3.RELEASE</version>
        <relativePath/> <!-- lookup parent from repository -->
    </parent>
    <groupId>com.publiclibrary</groupId>
    <artifactId>PublicLibrary</artifactId>
    <version>0.0.1-SNAPSHOT</version>
    <name>PublicLibrary</name>
    <description>Demo project for Spring data relationship</description>

    <properties>
        <java.version>1.8</java.version>
    </properties>

    <profiles>
        <profile>
            <id>cloud-gcp</id>
            <dependencies>
                <dependency>
                  <groupId>org.springframework.cloud</groupId>
                  <artifactId>spring-cloud-gcp-starter</artifactId>
                  <version>1.0.0.RELEASE</version>
                </dependency>
            </dependencies>
            <build>
              <plugins>
                <plugin>
                    <groupId>com.google.cloud.tools</groupId>
                    <artifactId>appengine-maven-plugin</artifactId>
                    <version>2.0.0-rc5</version>
                    <configuration>
                        <deploy.projectId>libraryapi-03312019</deploy.projectId>
                        <deploy.version>1.0</deploy.version>
                    </configuration>                
                </plugin>
              </plugins>
            </build>            
        </profile>
    </profiles>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-actuator</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-rest</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-validation</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>com.google.guava</groupId>
            <artifactId>guava</artifactId>
            <version>25.0-jre</version>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-devtools</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>com.h2database</groupId>
            <artifactId>h2</artifactId>
            <scope>runtime</scope>
        </dependency>
        <dependency>
            <groupId>org.projectlombok</groupId>
            <artifactId>lombok</artifactId>
            <optional>true</optional>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-test</artifactId>
            <scope>test</scope>
            <exclusions>
                <exclusion>
                    <groupId>org.assertj</groupId>
                    <artifactId>assertj-core</artifactId>
                </exclusion>
            </exclusions>
        </dependency>
    </dependencies>

    <build>
        <plugins>
            <plugin>
                <groupId>org.springframework.boot</groupId>
                <artifactId>spring-boot-maven-plugin</artifactId>
            </plugin>
        </plugins>
    </build>

</project>

我将不胜感激。

2 个答案:

答案 0 :(得分:0)

检查Google Cloud Platform的官方Springboot sample,以了解您可能会做些什么。

例如,我看到在 部分中,它需要 < / strong>:

 <properties>
    <java.version>1.8</java.version>
    <maven.compiler.source>${java.version}</maven.compiler.source> <!-- REQUIRED -->
    <maven.compiler.target>${java.version}</maven.compiler.target> <!-- REQUIRED -->
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
    <appengine.maven.plugin>1.3.2</appengine.maven.plugin>
  </properties>

请注意,appengine-maven-plugin使用的是版本 2.0.0-rc5 ,因此,如果将其添加到上述属性中,则应使用与插件部分相同的版本:

  <plugin>
    <groupId>com.google.cloud.tools</groupId>
    <artifactId>appengine-maven-plugin</artifactId>
    <version>${appengine.maven.plugin}</version>
  </plugin>

答案 1 :(得分:0)

谢谢。我遵循了示例应用程序,并将差异添加到我的pom.xml中。仅此一项并不能解决问题。此外,我将遗留的运行状况检查添加到允许部署该应用的app.yaml中(花费了相当长的时间)- 健康检查:   enable_health_check:是   check_interval_sec:5   timeout_sec:4   不健康阈值:2   Healthy_threshold:2

但是在部署后,当我尝试以 https:// :appspot.com 访问该应用程序时,我得到以下错误-

错误:服务器错误 服务器遇到临时错误,无法完成您的请求。 请在30秒内重试。

更新 我将资源部分添加到app.yaml中,因为在GAE中,已知this article

中标识的Java会消耗大量内存
resources:
  cpu: 2
  memory_gb: 2.3
  disk_size_gb: 10
  volumes:
  - name: ramdisk1
    volume_type: tmpfs
    size_gb: 0.5