简体   繁体   English

如何在App Engine v1.9.18中将app.yaml与Java运行时一起使用?

[英]How do I use app.yaml with Java runtime in App Engine v1.9.18?

I followed the documentation for using app.yaml with Java which claims that this should work and that it will generate web.xml and appengine-web.xml automatically. 我按照文档使用了app.yaml和Java ,声称这应该可行,并且它将自动生成web.xmlappengine-web.xml However, it doesn't seem to work and it doesn't mention which tool will generate the files. 但是,它似乎不起作用,并没有提到将生成文件的工具。

I first tried a mvn clean install which errors out because the .xml files are missing: 我首先尝试了一个mvn clean install ,因为缺少.xml文件而导致错误:

[ERROR] Failed to execute goal org.apache.maven.plugins:maven-war-plugin:2.4:war (default-war) on project roger-analytics: Error assembling WAR: webxml attribute is required (or pre-existing WEB-INF/web.xml if executing in update mode) -> [Help 1] [错误]无法执行目标org.apache.maven.plugins:maven-war-plugin:2.4:war(default-war)项目roger-analytics:组装WAR时出错:需要webxml属性(或预先存在的WEB- INF / web.xml如果在更新模式下执行) - > [帮助1]

I then tried to run the local development server: 然后我尝试运行本地开发服务器:

$ gcloud preview app run app.yaml
ERROR: (gcloud.preview.app.run) An error occurred while parsing file: [/Users/blixt/src/roger-api/module_analytics/app.yaml]
Unexpected attribute 'servlet' for object of type URLMap.
  in "/Users/blixt/src/roger-api/module_analytics/app.yaml", line 7, column 12

(I get the same error from dev_appserver.py . by the way) (我从dev_appserver.py .得到同样的错误dev_appserver.py .顺便说一下)

It appears that app.yaml isn't supported after all. 看来app.yaml毕竟不受支持。 Am I missing something, or was support removed without updating the documentation? 我是否遗漏了某些内容,或者删除了支持而未更新文档?

Here's my app.yaml file, which is intended to run as a module in my Google Cloud App Engine project (along with other modules that have Python and Go runtimes): 这是我的app.yaml文件,它旨在作为我的Google Cloud App Engine项目中的模块运行(以及其他具有Python和Go运行时的模块):

module: analytics
runtime: java
api_version: 1

handlers:
- url: /*
  servlet: im.rgr.roger.RogerAnalytics
  login: admin
  secure: always

system_properties:
  java.util.logging.config.file: WEB-INF/logging.properties

There are several issues at play here. 这里有几个问题在起作用。 I'll describe various facts that group together to create a constellation of SDK edge-case goodness (this information is current as of SDK 1.9.21): 我将描述组合在一起的各种事实,以创建一个SDK边缘案例的优势(此信息是SDK 1.9.21中的最新信息):

  • In order to deploy using the Java SDK 's appcfg.sh , you'll need to have app.yaml inside the war/WEB-INF/ folder. 要使用Java SDKappcfg.sh进行部署,您需要在war/WEB-INF/文件夹中包含app.yaml

  • appcfg.py complains Unexpected attribute 'servlet' for object of type URLMap. appcfg.py Unexpected attribute 'servlet' for object of type URLMap.抱怨了Unexpected attribute 'servlet' for object of type URLMap. .

  • gcloud preview app deploy uses appcfg.py (or the same codebase) and therefore also complains in the same manner gcloud preview app deploy使用appcfg.py (或相同的代码库),因此也以相同的方式抱怨


So, in conclusion, you'll need to use appcfg.sh 因此,总之,您需要使用appcfg.sh

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

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