Spring Boot 2 Lambda Microservices
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.
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
- 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.
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.
- Some of the major advantages of Spring Boot include:
- Creating easy to create stand-alone, production grade Spring based Applications that you can “just run”
- Automatically configure Spring and 3rd party libraries whenever possible
- Provide production-ready features such as metrics, health checks, and externalized configuration
- Reduces the time spend on development
- Easy integration with libraries of the Spring ecosystem including Spring Data, Spring Security, Spring ORM, and Spring JDBC
- Allows for easily connecting with database and queue services including Oracle, PostgreSQL, MySQL, MongoDB, Redis, Solr, ElasticSearch, Rabbit MQ, ActiveMQ, among others
- No code generation and no requirement for XML configuration
- Spring boot makes the Spring framework substantially more user-friendly
Spring Boot works well with a microservices approach which lends itself to Lambdas or Docker containers. Spring Boot is designed to reduce time on development and improve performance. Spring Boot is an extension of Spring to make development, testing, and deployment more convenient.
Do not hesitate to reach out to us at Accolite.com for more information about your organization’s cloud enablement or software development needs.