runtime:javaenv:flexruntime_config:operating_system:"ubuntu22"runtime_version:"21"handlers:-url:/.*script:this field is required, but ignoredmanual_scaling:instances:1
[[["容易理解","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 (世界標準時間)。"],[[["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file is essential for configuring an App Engine app, defining settings like CPU, memory, network, disk resources, scaling, and environment variables.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eapp.yaml\u003c/code\u003e acts as a deployment descriptor for a specific service version, and the default service must have an \u003ccode\u003eapp.yaml\u003c/code\u003e file created first.\u003c/p\u003e\n"],["\u003cp\u003eThe \u003ccode\u003eapp.yaml\u003c/code\u003e file allows for specifying the Java runtime configuration, including versions and URLs, and an example configuration is provided for the latest Java version.\u003c/p\u003e\n"],["\u003cp\u003eYou can customize the \u003ccode\u003eapp.yaml\u003c/code\u003e filename, but if you do, you must use the custom name when deploying your app with the \u003ccode\u003egcloud\u003c/code\u003e command.\u003c/p\u003e\n"],["\u003cp\u003eYou can configure your Java App Engine flexible environment to collect JVM metrics, such as garbage collection count and time, by setting JMX system properties in the \u003ccode\u003eapp.yaml\u003c/code\u003e environment variables.\u003c/p\u003e\n"]]],[],null,["# Configuring your app with app.yaml\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n| **Note:** Some [Java runtimes](/appengine/docs/flexible/lifecycle/support-schedule#java) have reached [end of support](/appengine/docs/flexible/lifecycle/runtime-lifecycle#end_of_support). You cannot re-deploy versions that use runtimes after their end of support date. We recommend that you [upgrade your app](/appengine/docs/flexible/java/runtime#newversions) to use the latest version of Java.\n\n\u003cbr /\u003e\n\n\nAn App Engine app is configured using an `app.yaml`\nfile, that contains CPU, memory, network and disk resources, scaling, and other\ngeneral settings including environment variables.\n\n\nAbout `app.yaml` files\n----------------------\n\n\u003cbr /\u003e\n\nYou can specify the runtime configuration for your Java app, including versions and URLs, in the `app.yaml` file. This file acts as a deployment descriptor of a specific [service](/appengine/docs/flexible/an-overview-of-app-engine) version.\n\n\u003cbr /\u003e\n\n\nYou must first create the `app.yaml` file for the `default` service of your app\nbefore you can create and deploy `app.yaml` files for additional services.\n\n\nThe following `app.yaml` sample demonstrates how to configure your app for\nthe [latest Java version](/appengine/docs/flexible/lifecycle/support-schedule#java).\nFor more information about using supported Java runtimes, see the\n[Java runtime](/appengine/docs/flexible/java/runtime). \n\n runtime: java\n env: flex\n runtime_config:\n operating_system: \"ubuntu22\"\n runtime_version: \"21\"\n handlers:\n - url: /.*\n script: this field is required, but ignored\n\n manual_scaling:\n instances: 1\n\n\nDepending on the complexity of your app's service, you might only need to define\na few elements in the corresponding `app.yaml` file. The following example\ndemonstrates what a simple Java app might require in the\nflexible environment:\n\n\nYou can specify a unique name for your `app.yaml` files, but then you must\nspecify the file name with the [deployment\ncommand](/appengine/docs/flexible/testing-and-deploying-your-app)\nas well. For example, if you name your `app.yaml` file `service-name-app.yaml`\nor `app.flexible.yaml`, then you must deploy your app using either: \n\n gcloud app deploy service-name-app.yaml\n gcloud app deploy app.flexible.yaml\n\nTo learn more about structuring multiple services and `app.yaml` files in your app, see [Structuring web services](/appengine/docs/flexible/configuration-files).\n\n\u003cbr /\u003e\n\nAll configuration elements\n--------------------------\n\nFor a complete list of all the supported elements in this configuration file,\nsee the\n[`app.yaml` reference](/appengine/docs/flexible/reference/app-yaml).\n\nEnabling Java Virtual Machine metrics collection\n------------------------------------------------\n\nYou can configure App Engine flexible environment for Java to collect common metrics for Java\nVirtual Machine (JVM) processes. The metrics are collected using the same\n[JVM monitoring plugin](/monitoring/agent/plugins/jvm)\nthat [Cloud Monitoring](/monitoring) uses. To view the full list of metrics\nfor App Engine, see the [Google Cloud metrics guide](/monitoring/api/metrics_gcp_a_b#gcp-appengine).\n\nIf you want to collect these JVM metrics for your app:\n\n- `appengine.googleapis.com/flex/instance/jvm/gc/count`\n- `appengine.googleapis.com/flex/instance/jvm/gc/time`\n\nyou'll need to set the following\n[JMX](http://www.oracle.com/technetwork/articles/java/javamanagement-140525.html) system\nproperties in the environment variables in your `app.yaml` and deploy your app. \n\n JAVA_USER_OPTS: \"-Djava.rmi.server.hostname=172.17.0.1 -Dcom.sun.management.jmxremote.port=10403 -\n Dcom.sun.management.jmxremote.rmi.port=10403 -Dcom.sun.management.jmxremote.local.only=false -\n Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false\"\n\n| **Note:** The `172.17.0.1` IP enables your container to connect to the JVM monitoring plugin running in App Engine flexible environment. Port 10403 is the reserved `JMX_PORT` on the app container which the monitoring plugin connects to."]]