Spring boot is a popular Java framework designed to help facilitate stand-alone, production-grade Spring based applications that can “just run”.

Many top companies use Spring Boot to support their backends including Netflix, Udemy, Trivago. Netflix adopted Spring Boot as its core Java framework.

Spring Boot provides various extension projects to build full stack microservices based on Java. With AWS Lambda, we can benefit from the serverless approach in the AWS environment. Specific benefits include avoiding server management, charged for what one uses, quick deployments.

In this demonstration, we will walk through deploying a Spring Boot2 Lambda.

Building a Spring Boot 2 Lambda

We are going to walk through some code provided by AWS Labs to create our Spring Boot 2 Lambda


  1. Set up your IDE and Java

A couple of options are to use either Eclipse or Visual Studio Code

If you prefer Eclipse, you could set it up as described in https://www.xerris.com/insights/getting-started-with-aws-java-11-amazon-corretto-eclipse-and-aws-toolkit/

If you wish to code Java with Visual Studio Code you can install Visual Studio Code from https://code.visualstudio.com/ and then you can follow the steps at https://code.visualstudio.com/docs/languages/java to be able to code in Java.

2. Install AWS CLI

3. Install AWS SAM CLI

4. Install Gradle or Maven

Project Setup

Download the code a folder, I have chosen to use a folder c:\projects\pet-store

Place the code located at https://github.com/awslabs/aws-serverless-java-container/tree/main/samples/springboot2/pet-store in this folder.

Open the project folder in your IDE to have a look.

Building and deploying the Spring Boot application to AWS

Ensure your AWS CLI is set up to the right account and region

cd c:\projects\pet-store
sam build
sam deploy --guided

Once you have deployed this project, you will be presented with an endpoint or microservice that you can test out

The actual endpoint code can be found in the PetsController class which defines the multiple endpoint urls and the code that is run. Note the Request Mapping annotations.

This is just an introductory starting point to show how to create a Spring Boot 2 Lambda with plenty of room to develop further.

Do not hesitate to reach out to us at Xerris.com for more information about your organization’s cloud enablement or software development needs.