错误将Spring webapp部署到Google Appengine

时间:2017-05-30 03:47:27

标签: google-app-engine spring-boot

首先,我很抱歉我的英语不好。 我有一个Springboot webapp项目,我想部署到appengine平台。问题是,当我使用命令if, else if, else在appengine端口8080中本地运行此项目时,它可以正常工作。但是,当我使用命令mvn spring-boot:run时出现错误

mvn appengine:deploy

我的项目的github链接here 我的pom.xml

[INFO] GCLOUD: ERROR: (gcloud.app.deploy) Error Response: [9] 
[INFO] GCLOUD: Application startup error:
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor       /lang/tt.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/lang/pt-br.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/lang/no.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/lang/nl.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/lang/zh-cn.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/lang/en-gb.js  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/ckeditor/CHANGES.md  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/css/style.css  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/static/css/bootstrap.min.css  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/static/client_secret.json  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/dao/NewsRepository.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/service/NewsService.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/controller/SampleRestController.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/controller/MainController.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/UploadFile.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/models/News.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/articleweb/Application.class  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/.application.properties.swp  
[INFO] GCLOUD:   inflating: /var/lib/jetty/webapps/root/WEB-INF/classes/application.properties
.................................................................
[INFO] GCLOUD: -XX:InitialHeapSize=514850816
-XX:MaxHeapSize=514850816 -XX:+ParallelRefProcEnabled  -XX:+PrintCommandLineFlags    -XX:+UseCompressedClassPointers -XX:+UseCompressedOops -XX:+UseG1GC 
[INFO] GCLOUD: openjdk version "1.8.0_121"
[INFO] GCLOUD: OpenJDK Runtime Environment (build 1.8.0_121-8u121-b13-1~bpo8+1-b13)
[INFO] GCLOUD: OpenJDK 64-Bit Server VM (build 25.121-b13, mixed mode)
[INFO] GCLOUD: 
[INFO] GCLOUD: 2017-05-30 02:17:21.237:INFO::main: Logging initialized @1794ms to org.eclipse.jetty.util.log.StdErrLog
[INFO] GCLOUD: 2017-05-30 02:17:22.251:INFO:oejs.SetUIDListener:main: Setting umask=02
[INFO] GCLOUD: 2017-05-30 02:17:22.292:INFO:oejs.SetUIDListener:main: Opened ServerConnector@29774679{HTTP/1.1,[http/1.1]}{0.0.0.0:8080}
[INFO] GCLOUD: 2017-05-30 02:17:22.294:INFO:oejs.SetUIDListener:main: Setting GID=999
[INFO] GCLOUD: 2017-05-30 02:17:22.299:INFO:oejs.SetUIDListener:main: Setting UID=999
[INFO] GCLOUD: 2017-05-30 02:17:22.309:INFO:oejs.Server:main: jetty-9.4.3.v20170317
[INFO] GCLOUD: 2017-05-30 02:17:22.496:INFO:oejdp.ScanningAppProvider:main: Deployment monitor      [file:///var/lib/jetty/webapps/] at interval 0
[INFO] GCLOUD: 
[INFO]   ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 06:43 min
[INFO] Finished at: 2017-05-30T09:20:05+07:00
[INFO] Final Memory: 22M/54M
[INFO] ------------------------------------------------------------------------

我对这个错误并不理想。另外,我不熟悉码头。希望有人帮助我。非常感谢您花时间阅读我的帖子。

2 个答案:

答案 0 :(得分:0)

由于缺少某些库,App Engine不允许使用Spring。

但您可以使用App Engine灵活环境

Hello World Example Spring App Engine

答案 1 :(得分:0)

尝试使用jar文件进行部署。

  1. 使用此插件:

      <plugin>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-maven-plugin</artifactId>
            <version>1.5.3.RELEASE</version>
            <executions>
                <execution>
                    <goals>
                        <goal>repackage</goal>
                    </goals>
                </execution>
            </executions>
        </plugin>
    
  2. 如果您有HTML等,请包含任何静态资源

    <resources>
            <resource>
             <!-- Must include this for static pages -->
                <directory>src/main/webapp</directory>
            </resource>
             <resource>
             <!-- Must include this for properties file -->
                <directory>src/main/resources</directory>
            </resource>
    

  3. 执行命令

    mvn clean package spring-boot:repackage