How to deploy a Spring Boot Application to Google App Engine

Let me show you how you what possibilities there are to deploy Spring Boot application to Google’s Cloud Platform. Google has recently introduced their free tier which gives you $300 worth of credit for a year and also under certain usage limits their services remain free. This is similar what Amazon has been offering for a wile, but goes even beyond that.

I have been using AWS for a long time and haven’t really followed Google Cloud Platform’s (GCP) advancement in the last two years. Their announcement caught my attention and thought I would give it a go.

Google App Engine Flexible Environment

Google App Engine (GAE) flexible environment lifts many restrictions of the standard environment. It gives you the flexibility to use any version of your chosen runtime and even to depend on native OS packages if necessary. Those Google Compute Engine (GCE) VMs which are behind your apps can also be customized with a Dockerfile. You can read a comparison on the two GAE environments here.

The flexible environment looks very similar to Amazon’s ElasticBeanstalk and I wanted to see how Spring Boot applications can be deployed to GAE.

Deploy Spring Boot Application in App Engine

Google has put a straight forward tutorial together, but at the time of writing it has a bug at step #7. I’ve filed an issue for this documentation bug here.

When you try to issue mvn gcloud:deploy, the following error occurs.

[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 4.128 s
[INFO] Finished at: 2017-03-18T18:05:09+01:00
[INFO] Final Memory: 19M/47M
[INFO] ------------------------------------------------------------------------
[ERROR] No plugin found for prefix 'gcloud' in the current project and in the plugin groups [org.apache.maven.plugins, org.codehaus.mojo] available from the repositories [local (/home/serviceprovider/.m2/repository), central (https://repo.maven.apache.org/maven2)] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/NoPluginFoundForPrefixException

Workaround

  1. Use the latest appengine maven plugin
    <build>
      <plugins>
        ...
        <plugin>
          <groupId>com.google.cloud.tools</groupId>
            <artifactId>appengine-maven-plugin</artifactId>
            <version>1.2.1</version>
        </plugin>
      </plugins>
    </build>
  2. Issue gcloud app deploy before that if your project doesn’t yet contain an app engine application
  3. Use mvn appengine:deploy instead of mvn gcloud:deploy

Conclusion

In conclusion, Google’s cloud services has evolved a lot. I really like their all in one command line tool (gcloud), the built-in cloud shell, the intuitive web interface and the way that GAE gives you all the infrastructure components an application needs. However,  GCP’s documentation apparently doesn’t always follow the latest developments.

That said, after completing their tutorial and reading through what the platform was capable of, I thought that folks would benefit from an extended example which demonstrates how caching, task queuing, scheduling can be implemented within a Spring Boot application leveraging GAE’s infrastructure.

Next Up

Leverage Google Flexible AppEngine to deploy Spring Boot applications is coming next week.

Laszlo Csontos
 

I've been coding since the age of 9. I knew from childhood that all I wanted to do was code. Now I've been coding for 25 years, with Java for 18 years and professionally for 13 years. During past projects I worked in various roles as a consultant, developer, mentor, team leader and architect. My focus areas have been database- oriented back-end applications, performance tuning techniques and distributed systems. In the last 3 years, I specialized in building microservices with the Spring Ecosystem and also contributed to some of its sub-projects. The newest venture of mine is the creation of craftingjava.com, which aims at helping young software engineers learn Spring.

Leave a Reply

avatar
  Subscribe  
Notify of