Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Regions-ID
REGION_ID ist ein abgekürzter Code, den Google anhand der Region zuweist, die Sie beim Erstellen Ihrer Anwendung ausgewählt haben. Der Code bezieht sich nicht auf ein Land oder eine Provinz, auch wenn einige Regions-IDs häufig verwendeten Länder- und Provinzcodes ähneln können. Bei Anwendungen, die nach Februar 2020 erstellt wurden, ist REGION_ID.r in den App Engine-URLs enthalten. Bei Anwendungen, die vor diesem Datum erstellt wurden, ist die Regions-ID in der URL optional.
In diesem Abschnitt des Leitfadens wird gezeigt, wie Sie mit der gcloud CLI den Java-Webdienst in App Engine bereitstellen. Weitere Informationen zur Java-Laufzeitumgebung und ihrer Funktionsweise finden Sie unter Java-Laufzeitumgebung.
Installieren Sie die Google Cloud CLI, in der das gcloud-Befehlszeilentool enthalten ist. Achten Sie darauf, dass gcloud für die Verwendung des Google Cloud Projekts konfiguriert ist, für das Sie die Bereitstellung vornehmen möchten.
Wichtige Fakten
Verwenden Sie gcloud app deploy und gcloud app browse, um Ihren Dienst bereitzustellen und aufzurufen.
Stellen Sie den Dienst bereit.
Führen Sie im Ordner my-java-service, in dem sich die Maven-POM- oder Gradle-Build-Datei befindet, folgenden Befehl in Ihrem Terminal aus:
gcloudappdeploy
Ihre Quelldateien werden dann in Cloud Storage hochgeladen. Cloud Build erstellt Ihre Anwendung und stellt sie in App Engine bereit.
Mehrere Dienste bereitstellen
Sie können Ihrem Projekt mehrere Dienste hinzufügen. Dazu erstellen Sie für jeden Dienst eine app.yaml-Datei. Fügen Sie das Attribut service in jede app.yaml-Datei ein, um den Namen des Dienstes anzugeben.
Weitere Informationen zum Strukturieren Ihrer Anwendung mit mehreren Diensten finden Sie unter Webdienste in App Engine strukturieren.
Jeder bereitgestellte Dienst hat eine eigene zugewiesene URL.
Ihren Dienst aufrufen:
Mit dem folgenden Befehl können Sie den Browser schnell starten und unter https://PROJECT_ID.REGION_ID.r.appspot.com auf Ihren Webdienst zugreifen:
gcloudappbrowse
Dienste und Versionen
Sie haben jetzt einen Dienst erstellt und in App Engine bereitgestellt.
Sie können den Namen Ihres Dienstes in der Datei app.yaml angeben. Wenn der Name weggelassen wird, wird er als default behandelt. Der erste Dienst, den Sie bereitstellen, muss der Standarddienst sein.
Sie können Ihren Dienst jederzeit aktualisieren, indem Sie den Befehl gcloud app deploy noch einmal ausführen. Bei jeder Bereitstellung wird eine neue Version erstellt und der Traffic wird automatisch an die neueste Version weitergeleitet.
So bestätigen Sie, dass Ihr Dienst erstellt und eine Version bereitgestellt wurde:
Rufen Sie Ihre App Engine-Dienste in der Google Cloud Console auf:
Sie sollten eine Version mit Zeitstempel sehen, die Ihrer Bereitstellung entspricht.
Informationen zum Senden von Anfragen an bestimmte Dienste und Versionen finden Sie unter Anfragerouting.
Nächste Schritte
Glückwunsch! Sie haben eine Anwendung erstellt, mit der hochgeladene Bilder gespeichert und klassifiziert werden können. Sie können der Anwendung nun noch weitere Features hinzufügen. Informationen dazu finden Sie auf folgenden Seiten:
Weitere Java-Codebeispiele für die App Engine-Standardumgebung sind im GitHub-Repository vonGoogle Cloud zu finden. Diese Beispiele können sowohl beide für Java verwendet werden.
[[["Leicht verständlich","easyToUnderstand","thumb-up"],["Mein Problem wurde gelöst","solvedMyProblem","thumb-up"],["Sonstiges","otherUp","thumb-up"]],[["Schwer verständlich","hardToUnderstand","thumb-down"],["Informationen oder Beispielcode falsch","incorrectInformationOrSampleCode","thumb-down"],["Benötigte Informationen/Beispiele nicht gefunden","missingTheInformationSamplesINeed","thumb-down"],["Problem mit der Übersetzung","translationIssue","thumb-down"],["Sonstiges","otherDown","thumb-down"]],["Zuletzt aktualisiert: 2025-09-04 (UTC)."],[[["\u003cp\u003eThe \u003ccode\u003eREGION_ID\u003c/code\u003e is a Google-assigned code based on the region selected during app creation, and it's included in App Engine URLs for apps created after February 2020.\u003c/p\u003e\n"],["\u003cp\u003eThe guide demonstrates how to use the \u003ccode\u003egcloud\u003c/code\u003e CLI to deploy a Java web service to App Engine, with the \u003ccode\u003egcloud app deploy\u003c/code\u003e command being the primary tool for this.\u003c/p\u003e\n"],["\u003cp\u003eMultiple services can be deployed within a single project by creating separate \u003ccode\u003eapp.yaml\u003c/code\u003e files for each service and specifying the \u003ccode\u003eservice\u003c/code\u003e attribute.\u003c/p\u003e\n"],["\u003cp\u003eAfter deploying a service, it can be accessed via a URL that follows the format \u003ccode\u003ehttps://PROJECT_ID.REGION_ID.r.appspot.com\u003c/code\u003e, and the \u003ccode\u003egcloud app browse\u003c/code\u003e command can launch the browser to this address.\u003c/p\u003e\n"],["\u003cp\u003eEach deployment of a service creates a new version, with traffic automatically routed to the latest one, and the first service deployed must be the default service.\u003c/p\u003e\n"]]],[],null,["# Deploy your web service\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\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/standard/python/how-requests-are-routed#region-id). \nOK\n\n\u003cbr /\u003e\n\n| **Note:** If you are deploying a new Java web service to Google Cloud, we recommend getting started with [Cloud Run](/run/docs/quickstarts/build-and-deploy/deploy-java-service).\n\nThis section of the guide shows how to use the gcloud CLI to deploy your\nJava web service on App Engine. To learn more about\nthe Java runtime environment, see\n[Java Runtime Environment](/appengine/docs/standard/java-gen2/runtime).\n\nBefore you begin\n----------------\n\n1. [Create a Google Cloud project with an App Engine app](/appengine/docs/standard/java-gen2/building-app/creating-project).\n2. [Write a Java web server ready to deploy on App Engine](/appengine/docs/standard/java-gen2/building-app/writing-web-service).\n3. [Install Google Cloud CLI](/sdk/docs/install), which provides the `gcloud` command-line tool. Ensure `gcloud` is configured to use the Google Cloud project you want to deploy to.\n\nKey points\n----------\n\n- Use `gcloud app deploy` and `gcloud app browse` to deploy and view your service.\n\nDeploy your service\n-------------------\n\nIn your `my-java-service` folder, where your Maven POM or\nGradle build file is located, run the following command in your terminal: \n\n gcloud app deploy\n\nYour source files are then uploaded to Cloud Storage. Cloud Build\nbuilds your app and deploys it to App Engine.\n| **Note:** Files listed in your [`.gcloudignore`](/sdk/gcloud/reference/topic/gcloudignore) file will not be uploaded.\n\n### Deploy multiple services\n\nYou can add multiple services in your project by creating an `app.yaml` file for each service. Include the\n`service` attribute in each `app.yaml` file to specify the name of the service.\nTo learn more about structuring your app using multiple services, see\n[Structuring Web Services in App Engine](/appengine/docs/standard/configuration-files#directory_structure).\n\nTo deploy multiple services, follow [these instructions](/appengine/docs/standard/testing-and-deploying-your-app#deploying_multiple_services)\n\nEach deployed service will have its own assigned URL.\n\nView your service\n-----------------\n\nTo quickly launch your browser and access your web service at\n\n`https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com`, use the following\ncommand: \n\n gcloud app browse\n\nServices and versions\n---------------------\n\nYou've just created and deployed a service on App Engine.\nYou can specify the name of your service in the `app.yaml` file. If the\nname is omitted, it is treated as `default`. The first service you deploy\nmust be the default service.\n\nYou can update your service at any time by running the `gcloud app deploy`\ncommand again. Each time you deploy, a new version is created and traffic\nis automatically routed to the latest version.\n\nTo confirm that your service has been created and a version has been deployed:\n\n1. View your App Engine services in the Google Cloud console:\n\n [View services](https://console.cloud.google.com/appengine/services)\n\n You should see one service listed, named `default`. The default service is\n publicly accessible at the following URL:\n\n\n `https://`\u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e`.`\u003cvar translate=\"no\"\u003e\u003ca href=\"#appengine-urls\" style=\"border-bottom: 1px dotted #999\" class=\"devsite-dialog-button\" data-modal-dialog-id=\"regional_url\" track-type=\"progressiveHelp\" track-name=\"modalHelp\" track-metadata-goal=\"regionalURL\"\u003eREGION_ID\u003c/a\u003e\u003c/var\u003e`.r.appspot.com`\n2. View your versions:\n\n [View versions](https://console.cloud.google.com/appengine/versions)\n\n You should see one timestamped version listed, corresponding to your\n deployment.\n\nTo learn how to send requests to specific services and versions, see\n[How Requests are Routed](/appengine/docs/standard/how-requests-are-routed).\n\nNext steps\n----------\n\nCongratulations! You built an application that can store and classify uploaded\nimages. Learn how to add other features to your application by exploring the\nfollowing pages:\n\n- See more Java code samples for the App Engine standard environment on the [Google Cloud GitHub repository.](https://github.com/GoogleCloudPlatform/java-docs-samples/). These samples can be used for both Java.\n- Learn more about writing application logs and interpreting system logs in [Reading and writing application logs](/appengine/docs/standard/writing-application-logs).\n- For a deeper dive into how App Engine works, see the [Java runtime environment](/appengine/docs/standard/java-gen2/runtime)."]]