Prior to deploying your application to App Engine, you can run and debug your App Engine standard application locally. This document describes how to configure the IDE for local run and debug from within IntelliJ IDEA.
Before you begin
Ensure your application is an App Engine standard project that contains an
appengine-web.xml
fileTo access the Cloud Client Libraries locally, complete the Adding Cloud Client Libraries to Your Maven Projects procedures.
Running your application locally
If you're using IntelliJ IDEA Ultimate Edition, you can run an App Engine application locally by following these instructions:
Select File > Open to open the project you want to run.
Browse to the directory containing your project.
Select Tools > Cloud Code > App Engine Run on a local App Engine Standard dev server.
The project takes a moment to build.
Editing the run configuration
Configure the server
You can edit the run configuration for your local server:
Select Run > Edit Configurations.
From the Run/Debug Configurations dialog, update configuration settings as needed. Some common settings include:
- Artifact to deploy.
- App Engine Host.
- App Engine Port.
Add environment variables
If needed, add environment variables to your configuration.
Select the Startup/Connection tab.
Select Run.
Select the Pass environment variables checkbox.
Add the necessary variables.
Select Debug.
Select the Pass environment variables checkbox.
Add the necessary variables.
When finished, click OK.
Stopping the server
To stop the Dev App Server, choose Run > Stop 'Google App Engine Standard Local Server'.
Debugging the application
You can use the run configuration you previously created to run your application in debug mode as follows:
Select Run > Debug.
In the dialog, click Google App Engine Standard Local Server.
After the project builds, you can set breakpoints to debug your app.
Debugging your application locally on Community Edition
IntelliJ Community Edition does not provide built-in support for running local Java servlet-based applications. To debug your application locally using IntelliJ Community Edition, configure your project to use the Maven or Gradle plugin.
Maven
Configuring your project using the Maven plugin
Add the App Engine Maven plugin to your project's
pom.xml
file.Create Run/Debug configuration for Maven.
Select Run > Edit Configurations.
Click + Add New Configuration.
Select Maven.
In the Command line field, enter
appengine:run
.Click OK.
Create a remote debug configuration.
Select Run > Edit Configurations.
Click + Add New Configuration.
Select Remote.
Ensure that the port number is the same as the port you configured in your Maven App Engine plugin configuration. Port 5005 is the default.
In the Before launch section, click + Add.
Select Run Another Configuration.
Select the run configuration for your Maven project.
Click OK.
To debug your application locally:
Select Run > Debug.
Select your remote debug configuration.
You can now debug your application locally.
Gradle
Configuring your project using the Gradle plugin
Create Run/Debug configuration for Gradle.
Select Run > Edit Configurations.
Click + Add New Configuration.
Select Gradle.
In the Gradle project field, select the module where you configured the
appengine-gradle-plugin
plugin.In the Tasks field, enter
appengineRun
.Click OK.
Create a remote debug configuration.
Select Run > Edit Configurations.
Click + Add New Configuration.
Select Remote.
Ensure that the port number is the same as the port you configured in your Gradle App Engine plugin configuration. Port 5005 is the default.
In the Before launch section, click + Add.
Select Run Another Configuration.
Select the run configuration for your Gradle project.
Click OK.
To debug your application locally:
Select Run > Debug.
Select your remote debug configuration.
You can now debug your application locally.
If the Attach Debugger link appears in the console log, click the link.
What's next
- Next, you can deploy your app to the App Engine standard environment.