【问题标题】:Error when deploying maven project to Google app engine将 maven 项目部署到 Google 应用引擎时出错
【发布时间】:2017-04-21 15:06:19
【问题描述】:

我试图将一个 maven 项目部署到 Google App Engine,但每当我在 cmd 中使用命令 mvn appengine:deploy 时,我都会收到此错误

    [INFO] GCLOUD:
    [INFO] ------------------------------------------------------------------------
    [INFO] BUILD FAILURE
    [INFO] ------------------------------------------------------------------------
    [INFO] Total time: 08:43 min
    [INFO] Finished at: 2017-04-21T21:43:13+07:00
    [INFO] Final Memory: 22M/287M
    [INFO] ------------------------------------------------------------------------
    [ERROR] Failed to execute goal com.google.cloud.tools:appengine-maven-
    plugin:1.2.1:deploy (default-cli) on project cc_w10: Execution default-cli 
    of goal com.google.cloud.tools:appengine-maven-plugin:1.2.1:deploy failed: 
    Non zero exit: 1 -> [Help 1]
    [ERROR]
    [ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
    [ERROR] Re-run Maven using the -X switch to enable full debug logging.
    [ERROR]
    [ERROR] For more information about the errors and possible solutions, please read the following articles:
    [ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/PluginExecutionException

这是我的 pom.xml

    <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/maven-v4_0_0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <groupId>org.cc_w10.sample</groupId>
    <artifactId>cc_w10</artifactId>
    <packaging>war</packaging>
    <version>0.0.1-SNAPSHOT</version>

    <parent>
        <groupId>org.springframework.boot</groupId>
        <artifactId>spring-boot-starter-parent</artifactId>
        <version>1.4.1.RELEASE</version>
    </parent>  

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

        <INSTANCE_CONNECTION_NAME></INSTANCE_CONNECTION_NAME>
        <user>user1</user>
        <password>1234</password>
        <database>sqldemo</database>
        <sqlURL>jdbc:mysql://google/sqldemo?cloudSqlInstance=cc-week-five:us-central1:root&amp;socketFactory=com.google.cloud.sql.mysql.SocketFactory&amp;user=root&amp;password=1234&amp;useSSL=false</sqlURL>

    </properties>

      <dependencies>
        <dependency>
          <groupId>org.springframework.boot</groupId>
          <artifactId>spring-boot-starter-web</artifactId>
        </dependency>

        <dependency>
            <groupId>javax.servlet</groupId>
            <artifactId>jstl</artifactId>
        </dependency>

        <dependency>
            <groupId>org.apache.tomcat.embed</groupId>
            <artifactId>tomcat-embed-jasper</artifactId>
            <scope>provided</scope>
        </dependency>

        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-data-jpa</artifactId>
        </dependency>    

        <dependency>
            <groupId>com.google.cloud.sql</groupId>
            <artifactId>mysql-socket-factory-connector-j-6</artifactId>
            <version>1.0.2</version>
        </dependency>

        <dependency>                       
            <groupId>mysql</groupId>
            <artifactId>mysql-connector-java</artifactId>
            <version>6.0.5</version>
        </dependency>

      </dependencies>

    <build>
        <finalName>cc_w10</finalName>    
        <plugins>
            <plugin>
                <groupId>com.google.cloud.tools</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.2.1</version>
            </plugin>
            <plugin>
                <groupId>com.google.appengine</groupId>
                <artifactId>appengine-maven-plugin</artifactId>
                <version>1.9.50</version>
            </plugin>   

            <plugin>
                <groupId>org.eclipse.jetty</groupId>
                <artifactId>jetty-maven-plugin</artifactId>
                <version>9.3.7.v20160115</version>
            </plugin>

            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-compiler-plugin</artifactId>
                <version>3.1</version>
                <configuration>
                    <source>1.8</source>
                    <target>1.8</target>
                </configuration>
            </plugin>      
        </plugins>    
    </build>
</project>

有谁知道如何解决这个问题?几天来我一直在寻找解决方案,但似乎没有希望。

【问题讨论】:

标签: java maven google-app-engine


【解决方案1】:

你的项目是一个 spring boot 项目,所以尝试使用 spring-maven 插件来生成 jar

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

【讨论】:

  • 您也尝试过启用 apppengine 插件??
  • 我的 pom.xml 中有 appengine 插件,这是否意味着它是自动启用的,还是我必须手动启用它?如果是这样,我该怎么做?
  • 根据documentation,您需要提供这两个插件,因为“spring-boot-maven-plugin”用于为您的应用创建 JAR 文件。然后,您可以使用使用“appengine-maven-plugin”的“mvn appengine:deploy”进行部署。
【解决方案2】:

我遇到了同样的问题,并尝试了不同的方法。

由于appengine:deploy 似乎没有复制我的app.yaml,而是创建了自己的,所以我尝试在粘贴我的 yaml 文件后直接在 target/appengine-staging 上使用 gcloud 命令。

然后我运行gcloud app deploy 并且由于我在app.yaml 中添加的这一行,它起作用了:

health_check: enable_health_check: False

从版本 1.3.0 开始,appengine 插件甚至没有检测到我的app.yaml。但是它设置在根文件夹上。我想它需要它在不同的位置/文件夹中,但我不知道是哪个。

【讨论】:

  • 我更新了应用程序并再次遇到了同样的问题......我认为这只是随机超时。我真的很惊讶这些基本功能不起作用。我对 Google 的期望更高...
  • 在我使用 gcloud app deploy 部署它后,它在 project.appspot.com 站点中显示“404 not found”,尽管在部署过程中没有错误。您知道为什么以及如何正确部署它吗?此外,当我将 health_check: enable_health_ check: False 添加到 app.yaml 时,它会显示:“错误:(gcloud.app.deploy) 解析文件时发生错误:[D:\WorkSpace\cc_w10\app.yaml] 无法分配值 'enable_health_check' 到属性 'health_check':"。抱歉我的评论乱七八糟。
  • 我通过将其添加到 yaml 文件中解决了部署错误:资源:memory_gb:4.0
【解决方案3】:

派对迟到了,但请确保您已将包装指定为“战争”。这解决了我的问题。

【讨论】:

    猜你喜欢
    • 2016-06-19
    • 2011-11-12
    • 2019-02-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 1970-01-01
    • 2015-01-08
    相关资源
    最近更新 更多