简体   繁体   English

将 Maven 项目部署到 Google 应用引擎时出错

[英]Error when deploying maven project to Google app engine

I was trying to deploy a maven project to Google App Engine, but whenever i use the command mvn appengine:deploy in cmd i get this error我试图将 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

Here's my pom.xml这是我的 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>

Does anyone know how to solve this problem?有谁知道如何解决这个问题? I've been looking for the solution for days but it seems hopeless.几天来我一直在寻找解决方案,但似乎没有希望。

your project is a spring boot project so try using spring-maven plugin to generate the jar你的项目是一个spring boot项目所以尝试使用spring-maven插件来生成jar

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

I had the same problem, and tried it a different way.我遇到了同样的问题,并尝试了不同的方法。

Since appengine:deploy didn't seem to copy my app.yaml but instead created its own, I tried to use gcloud commands directly on the target/appengine-staging after pasting my yaml file.由于appengine:deploy似乎没有复制我的app.yaml而是创建了自己的,因此我尝试在粘贴我的 yaml 文件后直接在目标/appengine-staging 上使用 gcloud 命令。

Then I run gcloud app deploy and it worked thanks to this line I added in app.yaml :然后我运行gcloud app deploy并且它的工作归功于我在app.yaml添加的这一行:

health_check: enable_health_check: False

Starting from version 1.3.0 the appengine plugin even doesn't detect my app.yaml in the first place.从版本 1.3.0 开始,appengine 插件甚至不会首先检测到我的app.yaml However it's set on the root folder.但是它设置在根文件夹中。 I suppose it requires it in a different place/folder but I don't know which one.我想它需要在不同的地方/文件夹中,但我不知道是哪个。

Pretty late to the party, but make sure you have specified the packaging as 'war'.聚会已经很晚了,但请确保您已将包装指定为“战争”。 That solved my issue.那解决了我的问题。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM