Spring Boot Application on AWS EC2 using Apache Tomcat
Posted On  January 3, 2023 | By Antony Basco 3 Min ReadÂ
Presently, everyone started to deploy their application on cloud services, developers started to explore better ways to deploy it.
Most of us started to use AWS not just because it provides free service for a year but also the feasibility and availability does help us to achieve our goal.
In this article we will deploy a spring boot application on tomcat service using AWS EC2.
Without further ado, let’s see the steps involved in it.
- Build Spring boot application war
- Set up a EC2 instance on AWS
- Install JDK and Apache Tomcat
- Deploy your application war in EC2.
Let’s see in detail
1.Build Spring boot application war:
This is the easiest step for all developers, you must be already aware of how to generate a war using IDE.
I have used maven tool in eclipse Ide to build my spring boot application war.
2.
Set up a EC2 instance on AWS.
Login to AWS management console, Search and Select service EC2
Don’t forget to select your region.
Now there will be several information required which you can input based on your requirement. For OS you can choose Amazon Linux 2 AMI (HVM)
Generate a keypair, create new security group to allow http(80), https and launch the instance. for more detailed information just refer document from amazon.
Install JDK and Apache Tomcat
Using the public ip / domain name and generated key pair, connect to the instance.
Either you can directly connect using aws console or by using putty.
Just follow the below steps.
 Update the system
Sudo yum update -y
Install java 17
sudo yum install java-17-amazon-corretto
Navigate to respective folder and download tomcat
wget -c https://dlcdn.apache.org/tomcat/tomcat-10/v10.1.7/bin/apache-tomcat-10.1.7.tar.gz
Extract tomcat
sudo tar xf apache-tomcat-10.1.7.tar.gz
3. Place the application war inside webapps folder.
4. Navigate to bin and start the server using./startup.sh