Introduction
This tutorial shows you how to deploy a sample Java application to Google App Engine using the App Engine Maven plugin.Here are the steps you will be taking.
- Build and run your "Hello, world!" app
You will learn how to run your app using Google Cloud Shell, right in your browser. At the end you'll deploy your app to the web using the App Engine Maven plugin. - After the app...
Your app will be real and you'll be able to experiment with it after you deploy, or you can remove it and start fresh.
Using Google Cloud Shell
Cloud Shell is a built-in command line tool for the console. We're going to use Cloud Shell to deploy our app.- Open Google Cloud ShellOpen Cloud Shell by clicking
from the navigation bar at the top. show me how - Clone the sample codeUse Cloud Shell to clone and navigate to the "Hello World" code. The sample code is cloned from your project repository to the Cloud Shell.
In Cloud Shell enter:
Clone a sample repository:
TUTORIALDIR=src/crawler-188409/java_gae_quickstart-2017-12-21-14-03
git clone https://github.com/GoogleCloudPlatform/appengine-try-java.git $TUTORIALDIR
cd $TUTORIALDIR
Configuring your deployment
You are now in the main directory for the sample code. We'll look at the files that configure your application.
- Exploring the applicationEnter the following command to view your application code:
cat src/main/java/myapp/DemoServlet.java
- This servlet responds to any request by sending a response containing the message
Hello, world!. - Exploring your configurationFor Java, Google App Engine uses XML files to specify a deployment's configuration.
Enter the following command to view your configuration file:
cat pom.xml
The
helloworld
app uses Maven, which means you must specify a Project Object Model, or
POM, which contains information about the project and configuration
details used by Maven to build the project.
Testing your app
- Test your app on Cloud ShellCloud Shell lets you test your app before deploying to make sure it's running as intended, just like debugging on your local machine.
To test your app enter:
mvn appengine:run - Preview your app with "Web preview"Your app is now running on Cloud Shell. You can access the app by using "Web preview" to connect to port 8080. show me how
- Terminating the preview instanceTerminate the instance of the application by pressing Ctrl+C in the Cloud Shell
Create the application
In order to deploy our app, we need to create an App Engine application. This sets up the app and selects a region.
To create your app enter:
gcloud app create- Deploying with Cloud ShellYou can use Cloud Shell to deploy your app. To deploy your app enter:
gcloud config set project crawler-188409 - Visit your appCongratulations! Your app has been deployed. The default URL of your app is crawler-188409.appspot.com Click the URL to visit it.
- View your app's statusYou can check in on your app by monitoring its status on the App Engine dashboard.
Open the menu on the left side of the console.
Then, select the App Engine section.
Last steps
mvn appengine:deploy
This article gives lot of information.Thanks
ReplyDeleteGoogle Cloud Platform Training
GCP Online Training
Google Cloud Platform Training In Hyderabad