App Engine 會使用這組版本 ID 判斷是否要使用指定 ID 建立新的應用程式版本,或是使用指定 ID 取代現有的應用程式版本 (如有)。您可以使用網址測試新版應用程式,在網址中使用「-dot-」做為子網域分隔符,例如 https://VERSION_ID-dot-default-dot-PROJECT_ID.REGION_ID.r.appspot.com。您可以使用 Google Cloud console選取應用程式的預設版本。如果未指定版本或指定的版本無效,系統就會載入預設版本。
部署期間完成的大部分工作會以名為「暫存」的準備步驟在本機進行,其中會執行組合 JAR 檔案、編譯 JSP 等工作。您可以在應用程式設定檔中使用暫存元素,選擇性地設定暫存行為的特定部分。大部分的應用程式都不需要使用者手動設定暫存行為,即可成功部署。如果您的應用程式無法部署,您可能必須透過下列選項來設定暫存。
元素
說明
<staging>
(非必要) 大部分應用程式都不需要變更預設行為。
暫存元素可讓您視部署作業的需要,指定特定的暫存設定。
這個元素可包含下列元素:
<enable-jar-splitting>
(非必要) 將大型 jar 檔案 (> 10MB) 拆分成較小的片段。(預設值:true)。
<jar-splitting-excludes>
指定以半形逗號分隔的檔案後置字元清單。如果啟用 enable-jar-splitting,所有與後置字元相符的檔案都會從所有 JAR 中排除。
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["難以理解","hardToUnderstand","thumb-down"],["資訊或程式碼範例有誤","incorrectInformationOrSampleCode","thumb-down"],["缺少我需要的資訊/範例","missingTheInformationSamplesINeed","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["其他","otherDown","thumb-down"]],["上次更新時間:2025-09-04 (世界標準時間)。"],[],[],null,["# App Engine appengine-web.xml reference\n\n### Region ID\n\nThe \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e is an abbreviated code that Google assigns\nbased on the region you select when you create your app. The code does not\ncorrespond to a country or province, even though some region IDs may appear\nsimilar to commonly used country and province codes. For apps created after\nFebruary 2020, \u003cvar translate=\"no\"\u003eREGION_ID\u003c/var\u003e`.r` is included in\nApp Engine URLs. For existing apps created before this date, the\nregion ID is optional in the URL.\n\nLearn more\n[about region IDs](/appengine/docs/legacy/standard/java/how-requests-are-routed#region-id). \nOK\n\nIn addition to the [`web.xml` deployment\ndescriptor](/appengine/docs/legacy/standard/java/config/webxml), App Engine Java\napplications use a configuration file, named `appengine-web.xml`,\nto specify information about your app and to identify which files in the app's\n`WAR` file are static files (like images) and which are resource files used by\nthe application.\n\nExample\n-------\n\nThe following example is a minimal file that specifies the Java 8\nruntime with no static files or resource files: \n\n \u003c?xml version=\"1.0\" encoding=\"utf-8\"?\u003e\n \u003cappengine-web-app xmlns=\"http://appengine.google.com/ns/1.0\"\u003e\n \u003cthreadsafe\u003etrue\u003c/threadsafe\u003e\n \u003cruntime\u003ejava8\u003c/runtime\u003e\n \u003c/appengine-web-app\u003e\n\nSyntax\n------\n\nAn App Engine Java app must have a file named `appengine-web.xml` in its\nWAR, in the directory `WEB-INF/`. This is an XML file whose root element is\n`\u003cappengine-web-app\u003e`.\n\nYou can find the Document Type Definition and schema specifications for the\n`appengine-web.xml` in the SDK's `docs/` directory.\n| **Note:** The standard `appengine-web.xml` file defines the default service. You will need to specify additional configuration parameters for each non-default service, which were formerly known as modules. These are described in the [overview of\n| App Engine](/appengine/docs/legacy/standard/java/an-overview-of-app-engine). You can also apply these configuration parameters to the default service.\n\n### Scaling elements\n\nThe following table lists the options for defining how you can specify that your\napplication should scale.\n\nFor a comparison of the performance features of the scaling types, see\n[Scaling dynamic instances](/appengine/docs/legacy/standard/java/how-instances-are-managed#scaling_dynamic_instances).\n\n### Staging elements\n\nMuch of the work done during a deployment occurs locally in a preparation step\ncalled *staging*, where JAR files are assembled, JSPs are compiled, and so forth.\nYou can optionally configure certain parts of the staging\nbehavior using staging elements in the application configuration file. Most\napplications will deploy successfully without manually configuring staging\nbehavior. If your app doesn't deploy, you may need to configure staging\nusing the options shown below.\n\n### Staging option defaults\n\nThe defaults for staging options are as follows:\n\n### Include and exclude syntax\n\nPath patterns are specified using zero or more `\u003cinclude\u003e` and\n`\u003cexclude\u003e` elements. In a pattern, `'*'` represents zero or more\nof any character in a file or directory name, and `**` represents zero or more\ndirectories in a path. Files and directories matching `\u003cexclude\u003e`\npatterns will not be uploaded when you deploy your app to App Engine. However,\nthese files and directories will still be accessible to your application when\nrunning on the local Development Server.\n\nAn `\u003cinclude\u003e` element overrides the default behavior of including\nall files. An `\u003cexclude\u003e` element applies after all\n`\u003cinclude\u003e` patterns (as well as the default if no explicit\n`\u003cinclude\u003e` is provided).\n\nThe following example demonstrates how to designate all `.png` files as static\nfiles (except those in the `data/` directory and all of its subdirectories): \n\n \u003cstatic-files\u003e\n \u003cinclude path=\"/**.png\" /\u003e\n \u003cexclude path=\"/data/**.png\" /\u003e\n \u003c/static-files\u003e\n\nYou can also set HTTP headers to use when responding to requests to these static\nresources. \n\n \u003cstatic-files\u003e\n \u003cinclude path=\"/my_static-files\" \u003e\n \u003chttp-header name=\"Access-Control-Allow-Origin\"\n value=\"http://example.org\" /\u003e\n \u003c/include\u003e\n \u003c/static-files\u003e\n\n| **Note:** If the `path` string doesn't start with a slash, then the HTTP headers, if any, work on App Engine but do **not** work on the Development Server.\n\nMIME types for static files\n---------------------------\n\nBy default, static files are served using a MIME type selected based on the\nfilename extension. You can associate custom MIME types with filename\nextensions for static files using `\u003cmime-mapping\u003e` elements in `web.xml`.\n\nURLFetch timeout\n----------------\n\nYou can set a deadline for each\n[URLFetch](/appengine/docs/legacy/standard/java/issue-requests#setting_a_request_timeout) request. By default, the deadline for a fetch is 5 seconds.\nYou can change this default by including the following setting in your\n`appengine-web.xml` configuration file. Specify the timeout in seconds: \n\n \u003csystem-properties\u003e\n \u003cproperty name=\"appengine.api.urlfetch.defaultDeadline\" value=\"10\"/\u003e\n \u003c/system-properties\u003e"]]