Mit Sammlungen den Überblick behalten
Sie können Inhalte basierend auf Ihren Einstellungen speichern und kategorisieren.
Apache Maven ist ein Build-Automatisierungstool für Java.
App Engine bietet ein Maven-Plug-in, mit dem Sie Ihre Anwendung erstellen und in App Engine bereitstellen können. Das Plug-in unterstützt keine Enterprise Application Archive(EAR)-Projekte.
Hinweis
Ermitteln Sie mit dem folgenden Befehl, ob Maven installiert ist und welche Version Sie haben:
mvn-v
Wenn Maven installiert ist, wird ein langer String mit Informationen angezeigt, der mit Apache Maven beginnt. Darauf folgt eine Versionsnummer wie 3.9.1.
Wenn Maven 3.9.1 oder höher nicht installiert ist:
Führen Sie, falls noch nicht erfolgt, die folgenden Schritte aus, um die gcloud CLI herunterzuladen, Ihr Google Cloud -Projekt zu erstellen und Ihre App Engine-Anwendung zu initialisieren.
Installieren Sie die app-engine-java-Komponente der gcloud CLI:
gcloudcomponentsinstallapp-engine-java
App Engine Maven-Plug-in hinzufügen
Wenn Sie das App Engine Maven-Plug-in verwenden möchten, fügen Sie dem Abschnitt plugins in der Datei pom.xml Ihres Projekts die folgenden Zeilen hinzu:
Nachdem Sie das Maven-Plug-in für App Engine der Datei pom.xml Ihres Projekts hinzugefügt haben, können Sie Ihre Anwendung mit dem folgenden Befehl erstellen:
Ersetzen Sie PROJECT_ID durch die ID Ihres Projekts. Google Cloud Wenn in der Datei pom.xml bereits Ihre Projekt-ID angegeben ist, müssen Sie das Attribut -Dapp.deploy.projectId nicht in dem von Ihnen ausgeführten Befehl einfügen.
Mit dem Ziel package wird die Anwendung erstellt und gepackt und das Ziel appengine:deploy führt Folgendes aus:
Generiert eine eindeutige Versions-ID für die neue Version Ihrer App.
Stellt die neue Version in App Engine bereit.
Leitet den gesamten Traffic zur neuen Version weiter.
Standardeinstellungen für die Bereitstellung ändern
Sie können das Standardbereitstellungsverhalten ändern, indem Sie Parameter im Befehl appengine:deploy übergeben. Der folgende Befehl stellt beispielsweise den in Ihrer Datei pom.xml definierten Dienst für ein bestimmtes Google Cloud Projekt bereit, weist dem Dienst eine benutzerdefinierte Versions-ID zu und deaktiviert die automatische Traffic-Weiterleitung für die neue Version:
[[["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\u003eApache Maven is a Java build automation tool, and the App Engine Maven plugin facilitates building and deploying Java applications to App Engine.\u003c/p\u003e\n"],["\u003cp\u003eBefore using the plugin, ensure Maven version 3.9.1 or newer is installed, and that the gcloud CLI and \u003ccode\u003eapp-engine-java\u003c/code\u003e component are also installed.\u003c/p\u003e\n"],["\u003cp\u003eThe App Engine Maven plugin is added to a project by modifying the \u003ccode\u003epom.xml\u003c/code\u003e file, specifying the \u003ccode\u003ecom.google.cloud.tools:appengine-maven-plugin\u003c/code\u003e with version \u003ccode\u003e2.8.1\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eThe command \u003ccode\u003emvn package appengine:deploy -Dapp.deploy.projectId=PROJECT_ID\u003c/code\u003e builds, packages, and deploys the application to App Engine, with the option to omit \u003ccode\u003e-Dapp.deploy.projectId\u003c/code\u003e if already specified in the \u003ccode\u003epom.xml\u003c/code\u003e.\u003c/p\u003e\n"],["\u003cp\u003eDeployment behavior can be customized using parameters in the \u003ccode\u003eappengine:deploy\u003c/code\u003e command, such as specifying a project ID, custom version ID, or disabling automatic traffic routing.\u003c/p\u003e\n"]]],[],null,["# Using Apache Maven and the App Engine Plugin\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\n[Apache Maven](http://maven.apache.org/) is a\nbuild automation tool for Java.\n\nApp Engine provides a Maven plugin that you can use to build and deploy\nyour app to App Engine. The plugin does not support Enterprise\nApplication Archive (EAR) projects.\n| **Note:** For information about other ways to build and deploy your app, see [Testing and deploying your app](/appengine/docs/standard/testing-and-deploying-your-app).\n\nBefore you start\n----------------\n\n1. Determine if Maven is installed and which version you have by running\n the following command:\n\n mvn -v\n\n If Maven is installed, a long string of information beginning with\n `Apache Maven` and followed by a version number such as `3.9.1` will\n display.\n2. If you don't have Maven 3.9.1 or newer installed:\n\n 1. [Download](https://maven.apache.org/download.cgi) Maven 3.9.1 or newer.\n 2. [Install](https://maven.apache.org/install.html) Maven 3.9.1 or newer.\n\n | **Note:** Linux users might need to download Maven instead of using `apt-get install` to install Maven 3.9.1 or newer.\n3. If you haven't already done so, follow the steps\n [here](/appengine/docs/standard/setting-up-environment)\n to download the gcloud CLI, create your Google Cloud project, and\n initialize your App Engine app.\n\n4. Install the gcloud CLI `app-engine-java` component:\n\n gcloud components install app-engine-java\n\nAdding the App Engine Maven plugin\n----------------------------------\n\nTo use the [App Engine Maven plugin](https://github.com/GoogleCloudPlatform/appengine-plugins/tree/main/app-maven-plugin), add the following lines to the `plugins` section in\nyour project's `pom.xml` file: \n\n \u003cplugin\u003e\n \u003cgroupId\u003ecom.google.cloud.tools\u003c/groupId\u003e\n \u003cartifactId\u003eappengine-maven-plugin\u003c/artifactId\u003e\n \u003cversion\u003e2.8.1\u003c/version\u003e\n \u003c/plugin\u003e\n\n| **Note:** If there is a newer version of the App Engine Maven plugin, you should upgrade to the [latest version](http://mvnrepository.com/artifact/com.google.cloud.tools/appengine-maven-plugin).\n\nBuilding and deploying your app\n-------------------------------\n\nAfter you add the App Engine Maven plugin to your project's `pom.xml`\nfile, you can use the following command to build deploy your app: \n\n```\nmvn package appengine:deploy -Dapp.deploy.projectId=PROJECT_ID\n```\n\nReplace \u003cvar translate=\"no\"\u003ePROJECT_ID\u003c/var\u003e with the ID of your Google Cloud project. If\nyour `pom.xml` file already\n\n[specifies your\nproject ID](/appengine/docs/standard/java-gen2/maven-reference#appenginedeploy)\n, you don't need to include the `-Dapp.deploy.projectId` property in the\ncommand you run.\n\nThe `package` goal builds and packages your app, and the\n\n[`appengine:deploy` goal](/appengine/docs/standard/java-gen2/maven-reference#appenginedeploy)\n\ndoes the following:\n\n1. Generates a unique version ID for the new version of your app.\n\n2. Deploys the new version to App Engine.\n\n3. Routes all traffic to the new version.\n\nChanging the deployment defaults\n--------------------------------\n\nYou can change the default deployment behavior by passing parameters in the\n`appengine:deploy` command. For example, the following command deploys the\nservice defined in your `pom.xml` file to a specific Google Cloud project,\nassigns a custom version ID to the service, and turns off automatic traffic\nrouting for the new version: \n\n```bash\nmvn appengine:deploy -Dapp.deploy.projectId=PROJECT_ID -Dapp.deploy.version=VERSION_ID -Dapp.deploy.promote=False\n```\n\nYou can also use the `appengine:deploy` command to deploy configuration files,\nsuch as `cron.yaml`, `dispatch.yaml`, and `index.yaml`.\n\nFor more information, see the `appengine:deploy`\n\n[reference](/appengine/docs/standard/java-gen2/maven-reference#appenginedeploy)\n.\n\nWhat's next\n-----------\n\n- Review the [JDK 21 App Engine Maven plugin sample](https://github.com/GoogleCloudPlatform/java-docs-samples/tree/main/appengine-java21/helloworld).\n- Explore the plugin code and report issues on [GitHub](https://github.com/GoogleCloudPlatform/app-maven-plugin).\n- Learn how to specify parameters for tasks by referring to [App Engine Maven Goals and Parameters](/appengine/docs/standard/java-gen2/maven-reference#appenginedeploy)."]]