【问题标题】:How to deploy Spring Boot application to Google Managed VM如何将 Spring Boot 应用程序部署到 Google Managed VM
【发布时间】:2015-01-03 06:01:18
【问题描述】:

我有一个 Spring Boot 应用程序,我正在尝试找出将其部署到 Google 新的托管 VM 环境(这些是能够运行 Docker 容器的 VM)的位。我已经开始使用以下内容定义 app.yaml:

application: myapp-1
version: 1
runtime: java
api_version: 1
vm: true
handlers:
  - url: /*
  servlet: org.springframework.web.servlet.DispatcherServlet
  init_params:
    contextAttribute: org.springframework.web.context.WebApplicationContext.ROOT

然后我运行以下命令从我的应用程序根目录中进行测试:

gcloud --verbosity debug preview app run .

我一直在反复试验,现在遇到以下异常:

Unknown url handler type.
<URLMap 
    secure=default 
    static_files=None 
    application_readable=None 
    auth_fail_action=redirect 
    require_matching_file=None 
    static_dir=None 
    redirect_http_response_code=None 
    http_headers=None 
    url=/* 
    script=None 
    upload=None 
    api_endpoint=None 
    expiration=None 
    position=None 
    login=optional 
    mime_type=None
    >

我使用https://cloud.google.com/appengine/docs/java/configyaml/appconfig_yaml 作为指导,但我开始怀疑托管 VM 环境是否支持 app.yaml 格式。

这里有一个类似的例子https://github.com/GoogleCloudPlatform/appengine-java-vm-guestbook-extras,但它不使用 app.yaml 格式。

最近有没有让 Spring Boot 应用在 Google 托管 VM 中运行的示例?

【问题讨论】:

    标签: google-app-engine docker spring-boot google-compute-engine


    【解决方案1】:

    我只看到了在 Google AppEngine https://github.com/scratches/spring-boot-sample-gae 上运行 SprinBoot 应用程序的示例

    Google 还添加了few hints,说明如何为 Google AppEngine 优化 SpringApp(我认为它也适用于 Google Managed Vm)

    您还可以查看 SpringBoot 部署提示 (http://spring.io/blog/2014/03/07/deploying-spring-boot-applications),尤其是部署到 Jetty 容器中的部分(通常 GAE 使用 Jetty 容器 afaik)

    我也在尝试在 ManagedVm 上部署这样一个使用 GoogleDatastore 的 SpringBoot 应用程序,所以我很快就会让你知道我的发现!继续努力!

    【讨论】:

      【解决方案2】:

      YAML 文件使用缩进来精确定义结构。您可以尝试将servletinit_params 的行缩进,但需要很多空格,直到它们像示例here 那样排成一行?或者这只是 StackOverflow 破坏您粘贴的 YAML 的一个案例?

      【讨论】:

        猜你喜欢
        • 2015-10-27
        • 2018-03-16
        • 2021-07-25
        • 2016-03-25
        • 2015-01-25
        • 2018-10-31
        • 2014-05-03
        • 2016-01-16
        • 2021-08-17
        相关资源
        最近更新 更多