Mantenha tudo organizado com as coleções
Salve e categorize o conteúdo com base nas suas preferências.
ID da região
O REGION_ID é um código abreviado que o Google atribui
com base na região que você selecionou ao criar o aplicativo. O código não
corresponde a um país ou estado, ainda que alguns IDs de região sejam semelhantes
aos códigos de país e estado geralmente usados. Para apps criados após
fevereiro de 2020, o REGION_ID.r está incluído nos
URLs do App Engine. Para apps existentes criados antes dessa data, o
ID da região é opcional no URL.
Esta seção do guia mostra como usar a CLI gcloud para implantar seu
serviço da Web Java no App Engine. Para saber mais sobre
o ambiente de execução do Java, consulte
ambiente de execução do Java.
Instale a Google Cloud CLI, que fornece a ferramenta de linha de comando
gcloud. Verifique se gcloud está configurado para usar o projeto Google Cloud em que você quer implantar.
Pontos principais
Use gcloud app deploy e gcloud app browse para implantar e visualizar seu serviço.
Implante seu serviço
Na pasta my-java-service, onde o arquivo de compilação Maven POM ou Gradle está localizado, execute o seguinte comando no terminal:
gcloudappdeploy
Seus arquivos de origem são enviados para o Cloud Storage. O Cloud Build cria seu aplicativo e o implanta no App Engine.
Implantar vários serviços
É possível adicionar vários serviços no seu projeto criando um arquivo app.yaml para cada um deles. Inclua o atributo service em cada arquivo app.yaml para especificar o nome do serviço.
Para saber mais sobre como estruturar o aplicativo usando vários serviços, consulte
Como estruturar serviços da Web no App Engine.
Cada serviço implantado terá o próprio URL atribuído.
Ver seu serviço
Para iniciar rapidamente seu navegador e acessar seu serviço da Web em https://PROJECT_ID.REGION_ID.r.appspot.com, use o seguinte comando:
gcloudappbrowse
Serviços e versões
Você acabou de criar e implantar um serviço no App Engine.
Você pode especificar o nome do serviço no arquivo app.yaml. Se o nome for omitido, ele será tratado como default. O primeiro serviço que você implanta precisa ser o padrão.
Você pode atualizar seu serviço a qualquer momento executando o comando gcloud app deploy novamente. A cada implantação, uma nova versão é criada e o tráfego é roteado automaticamente para a versão mais recente.
Para confirmar que o serviço foi criado e uma versão foi implantada:
Confira os serviços do App Engine no console Google Cloud :
Parabéns! Você criou um aplicativo que pode armazenar e classificar imagens carregadas. Saiba como adicionar outros recursos ao aplicativo explorando as seguintes páginas:
Confira mais exemplos de código Java para o ambiente padrão do App Engine
no repositório GitHub doGoogle Cloud . Esses exemplos podem ser usados para Java.
[[["Fácil de entender","easyToUnderstand","thumb-up"],["Meu problema foi resolvido","solvedMyProblem","thumb-up"],["Outro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Informações incorretas ou exemplo de código","incorrectInformationOrSampleCode","thumb-down"],["Não contém as informações/amostras de que eu preciso","missingTheInformationSamplesINeed","thumb-down"],["Problema na tradução","translationIssue","thumb-down"],["Outro","otherDown","thumb-down"]],["Última atualização 2025-08-11 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)."]]