Deploy Java Spring API on GCP App Engine

Deploy Java Spring API on GCP App Engine

Introduction

Deploying applications to the cloud involves managing various components such as servers, operating systems, libraries, and networks. For developers seeking a simplified approach where they can focus solely on their application and data, serverless solutions present an attractive option. In this article, we’ll explore serverless options on Google Cloud Platform (GCP), with a specific focus on App Engine.

App Engine

GCP offers several serverless solutions, including Cloud Run, Cloud Function, service integration, and App Engine. App Engine, in particular, provides a fully managed platform that enables the development and deployment of scalable web applications without the need for server management or infrastructure concerns.

App Engine supports applications in various programming languages such as Node.js, Java, Ruby, C#, Go, Python, or PHP.

The platform employs a hierarchical structure comprising services, versions, and instances, allowing for effective management and scaling of applications.

  • Service: Use services in App Engine to factor your large apps into logical components that can securely share App Engine features and communicate with one another.

  • Version: Having multiple versions of your app within each service allows you to quickly switch between different versions of that app for rollbacks, testing, or other temporary events.

  • Instance: the versions within your services run on one or more instances.

Deployment

Let’s dive into the practical part of deploying a Java Spring API on App Engine.

You should first create your gcp project then open the cloud shell and run the below commands.

  • Set the project: Open the Cloud Shell and set your GCP project using the following command:
gcloud config set project <project-id>
  • Clone the application
git clone https://github.com/ntepp/random-bible-verse
  • Update pom.xml: Add the App Engine Maven plugin to your pom.xml either using the GCP Visual Editor or a text editor like Vi:
<plugin>
   <groupId>com.google.cloud.tools</groupId>
   <artifactId>appengine-maven-plugin</artifactId>
   <version>2.7.0</version>
</plugin>
  • Deploy the Maven app (it
gcloud app deploy pom.xml --no-cache

During deploying the application, they should ask you about the region (carefully choose the region) and confirm some stuff.

Conclusion

In this article, we explored the process of deploying a Java Spring API on GCP App Engine, a serverless platform that streamlines application development and deployment. By leveraging App Engine’s managed environment, developers can focus on building robust applications without the complexities of server management. Simplifying the deployment process allows for a more efficient and seamless experience, making serverless options an excellent choice for developers on Google Cloud Platform.