简体   繁体   English

如何使用Eclipse IDE在Google App Engine(GAE)上部署Spring Boot应用程序?

[英]How to deploy Spring Boot application on Google App Engine(GAE) using Eclipse IDE?

I've created a spring boot application, and I want to deploy it on Google App Engine(GAE). 我已经创建了一个Spring Boot应用程序,并且希望将其部署在Google App Engine(GAE)上。 With reference to that following are the things I've done. 关于这一点,以下是我所做的事情。

  1. Created spring boot app 创建了Spring Boot应用
  2. Added appengine-web.xml and web.xml under webapp/WEB-INF 在webapp / WEB-INF下添加了appengine-web.xml和web.xml
  3. Configured Project ID and Version details under Google app engine settings 在Google App Engine设置下配置的项目ID和版本详细信息
  4. install maven depencencies using Maven install 使用Maven install安装Maven依赖

Now, when I try to run my application using spring boot or google web application, it gives tomcat connection error. 现在,当我尝试使用Spring Boot或Google Web应用程序运行我的应用程序时,它会显示tomcat连接错误。

Following are the related files, appengine-web.xml 以下是相关文件appengine-web.xml

<?xml version="1.0" encoding="utf-8"?>
<appengine-web-app xmlns="http://appengine.google.com/ns/1.0">
    <application>appname</application>
    <version>1</version>
    <threadsafe>true</threadsafe>
</appengine-web-app>

web.xml web.xml

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">

    <context-param>
        <param-name>contextConfigLocation</param-name>
        <param-value>org.example.Application</param-value>
    </context-param>

    <listener>
        <listener-class>org.springframework.boot.legacy.context.web.SpringBootContextLoaderListener</listener-class>
    </listener>

    <filter>
        <filter-name>metricFilter</filter-name>
        <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
    </filter>

    <filter-mapping>
        <filter-name>metricFilter</filter-name>
        <url-pattern>/*</url-pattern>
    </filter-mapping>

    <servlet>
        <servlet-name>appServlet</servlet-name>
        <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
        <init-param>
            <param-name>contextAttribute</param-name>
            <param-value>org.springframework.web.context.WebApplicationContext.ROOT</param-value>
        </init-param>
        <load-on-startup>1</load-on-startup>
    </servlet>

    <servlet-mapping>
        <servlet-name>appServlet</servlet-name>
        <url-pattern>/</url-pattern>
    </servlet-mapping>

</web-app>

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.example</groupId>
    <artifactId>spring-boot-fundamentals</artifactId>
    <version>1.0-SNAPSHOT</version>

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

    <properties>
        <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
        <java.version>1.7</java.version>
    </properties>

    <dependencies>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-web</artifactId>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-starter-tomcat</artifactId>
            <scope>provided</scope>
        </dependency>
        <dependency>
            <groupId>org.springframework.boot</groupId>
            <artifactId>spring-boot-legacy</artifactId>
            <version>1.0.2.RELEASE</version>
        </dependency>
    </dependencies>

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

Before Spring Boot, I used to deploy an application to GAE using Google plugin. 在Spring Boot之前,我曾经使用Google插件将应用程序部署到GAE。 But for Spring Boot application, it's completely different. 但是对于Spring Boot应用程序,则完全不同。 Just add appengine-web.xml and web.xml files under webapp/WEB-INF folder and use "mvn appengine:update" to deploy the application. 只需在webapp / WEB-INF文件夹下添加appengine-web.xml和web.xml文件,然后使用“ mvn appengine:update”来部署该应用程序。

You are missing a number of the steps required to convert a Spring Boot application for App Engine Standard . 您缺少为App Engine Standard转换Spring Boot应用程序所需的许多步骤。 In your particular case you need to: 在您的特定情况下,您需要:

Or you could simply base yourself on the configuration in this sample Spring Boot application . 或者,您可以简单地基于此示例Spring Boot应用程序中的配置。

I would go into more details but then I'd simply be rewriting the source material, which I encourage you to read. 我将进一步介绍细节,但是之后我将只重写源材料,我鼓励您阅读这些源材料。

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

相关问题 如何将Spring Boot(1.3.6)或任何Spring Boot项目(连接到云数据库)部署到Google App Engine? - How to deploy Spring Boot (1.3.6) or any Spring Boot project (connection to cloud database) to Google App Engine? 如何将 SpringBoot 应用程序部署到 Google App Engine? - How to deploy a SpringBoot Application to Google App Engine? GAE中的Spring Hibernate错误(Google App Engine) - Spring Hibernate error in GAE (Google App Engine) 使用应用引擎部署本地主机上的谷歌云应用引擎和 Spring Boot 错误 - google cloud app engine and spring boot bug on localhost deploy with app engine 部署后无法访问Google App Engine中的Spring Boot应用程序 - Unable to access Spring Boot application in Google App Engine after deployment 在 Google Cloud App Engine 上构建 Spring Boot 应用程序的触发器 - Build trigger for Spring Boot application on Google Cloud App Engine 在 Google App Engine 上部署 Spring Boot 应用程序时出错 - Error while deploying spring boot application on google app engine 在Google App Engine上部署现有的Spring Boot应用程序 - Deploying Existing Spring Boot Application on Google App Engine 如何初始化 firebase 托管在谷歌应用引擎上的 spring-boot 应用程序 - How can I initialize firebase a spring-boot application hosted on google app-engine 谷歌云应用引擎 Spring 部署错误 - Google cloud App engine Spring deploy error
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM