Deploying Spring Boot project on GCP App Engine Standard

App Engine is well suited to applications that are designed using a microservice architecture.

If you search on google how to deploy a Spring Boot project on Google App Engine, you will find a lot of old documentation, which talks about changing the Application code so that you are able to deploy it to the app engine.

For example, some mandatory steps mentioned are:

  1. You can only deploy a WAR file instead of a JAR file.
  2. You need to implement SpringBootServletInitializer
  3. Remove Tomcat Starter
  4. Add Servlet API dependency
  5. Exclude JUL to SLF4J Bridge
  6. adding logging.properties file with .info tag

Google’s GitHub link also mentions these steps as mandatory.

Edit: Above documentation is Fixed after this issue was opened https://github.com/GoogleCloudPlatform/getting-started-java/issues/505

This is a lot of work

But thankfully all this is not required.

Now you can deploy a JAR file to App Engine Standard Environment without doing all these.

You just have to build the JAR and choose Java 11 runtime to deploy the app.

If you have an existing spring boot app, and you want to migrate to a JAR version from a WAR deployment, check this link

The Java 11 runtime does not include any web-serving framework, meaning you’re no longer limited to servlet-based frameworks.

You can use all the popular frameworks on App Engine with Java 11 Runtime

Before ending this article let’s discuss the differences in JAR and WAR

WAR file is simply a JAR file but contains only Web-related Java files like Servlets, JSP, HTML.

To execute a WAR file, a Web server or Web container is required, for example, Tomcat

JAR file contains Java-related resources like libraries, classes, etc. which you can run directly from the JDK, in Spring Boot jar Web server is embedded in the jar.

And one last thing, there is one more environment on Google App Engine, i.e Flexible Environment

On Flexible Environment Application instances run within Docker containers on Compute Engine virtual machines

One other important difference is that :

In Standard Environment, you get Scale to zero but in Flexible you will have at least minimum 1 instance running

For the complete difference between these two environments check this link

You can also watch this video, all the steps are shown in the video

or take this CodeLab

A sample project is uploaded at this Github link

If you found this article useful, you know what to do now. Hit that clap button and star the GitHub repo follow me to get more articles and tutorials on your feed.