If you are migrating to the latest supported Java version and your app does not use legacy bundled services, you must re-package your App Engine Java 8 web application into an executable JAR file.
Your application must have a Main class that starts a web server that responds
to HTTP requests on port 8080, which might be specified by the PORT environment
variable.
For example:
WAR migration example (Java 11)
The following instructions demonstrate how to repackage an App Engine
Java 8 hello-world application as a JAR to run on the Java 11 runtime.
The migration uses the appengine-simple-jetty-main artifact. This provides a
Main class with a simple Jetty web server that loads a WAR file and packages
your app into an executable JAR file:
Clone the Embedded Jetty Server artifact to your local machine:
git clone https://github.com/GoogleCloudPlatform/java-docs-samplesAlternatively, you can download the sample as a zip file and extract it.
Change to the directory that contains the sample code:
cd java-docs-samples/appengine-java11/appengine-simple-jetty-main/Install the dependency locally:
mvn installAdd the following code to your project
pom.xmlfile:appengine-simple-jetty-maindependency:maven-dependencyplugin: App Engine deploys files located in the${build.directory}/appengine-stagingdirectory. By adding themaven-dependencyplugin to your build, App Engine installs your specified dependencies to the correct folder.
Create an
entrypointelement in yourapp.yamlfile to call theappengine-simple-jetty-mainobject and pass your WAR file as an argument. For example, see thehelloworld-servletsampleapp.yamlfile:To run your application locally:
Package your application:
mvn clean packageStart the server with your WAR file as an argument.
For example, you can start the server in the
helloworld-servletsample by running the following command from yourjava-docs-samples/appengine-java11/appengine-simple-jetty-main/folder:mvn exec:java -Dexec.args="../helloworld-java8/target/helloworld.war"In your web browser, enter the following address:
To deploy your application:
gcloud tooling
gcloud app deploy
Maven plugin
mvn package appengine:deploy -Dapp.deploy.projectId=PROJECT_ID
Replace PROJECT_ID with the ID of your Google Cloud project. If your
pom.xmlfile already specifies your project ID , you don't need to include the-Dapp.deploy.projectIdproperty in the command you run.