{"id":98807,"date":"2019-10-01T10:00:45","date_gmt":"2019-10-01T07:00:45","guid":{"rendered":"https:\/\/www.javacodegeeks.com\/?p=98807"},"modified":"2019-09-30T12:27:40","modified_gmt":"2019-09-30T09:27:40","slug":"deploy-spring-boot-application-aws-ec2-instance","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html","title":{"rendered":"How to deploy a Spring Boot Application on AWS EC2 instance"},"content":{"rendered":"<p>Hello Friends,<\/p>\n<p>In this tutorial,we will see how we can deploy a Spring Boot application over an AWS EC2 instance.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"320\" height=\"180\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/springBootAwsEc2.jpg\" alt=\"\" class=\"wp-image-98817\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/springBootAwsEc2.jpg 320w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/springBootAwsEc2-300x169.jpg 300w\" sizes=\"(max-width: 320px) 100vw, 320px\" \/><\/figure>\n<\/div>\n<p>Here are the steps we are going to perform.<\/p>\n<p><b>1. Create a Spring Boot Project with Spring Boot Initialiser.<\/b><br \/><b>2. Create a Rest end Point,which we can access after deployment<\/b><br \/><b>3. Launch an EC2 instanc<\/b>e<br \/><b>4. Copy our Spring Boot project from our\u00a0 local machine to EC2 instance<\/b><br \/><b>5. Connect to EC2 instance using SSH<\/b><br \/><b>6. Remove JDK 7 and install JDK 8 over EC2 instance<\/b><br \/><b>7. Execute the spring boot jar on EC2 instance<\/b><br \/><b>8. Make sure your Security group allows the inbound traffic from internet over port 8080 and using TCP protocol<\/b><br \/><b>9. Test the Application by hitting the endpoint URL from browser<\/b>\u00a0.<\/p>\n<p><b><br \/><\/b> So,Let us see step by step&#8230;.<\/p>\n<h2 class=\"wp-block-heading\"><b>1. Create a Spring Boot Project with Spring Boot Initialiser<\/b><\/h2>\n<p><b><br \/><\/b> You can follow one of my previous tutorials where in I explained step by step how you can create a spring boot project using Spring Initialiser.Here is the link.<\/p>\n<p><a href=\"https:\/\/www.javacodegeeks.com\/2018\/02\/create-spring-boot-project-spring-initializer.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How to create a Spring Boot Project with Spring Initialiser<\/a><\/p>\n<p>For this example ,I have given name &#8220;springbootproject&#8221; to the project,so you can give the same name,as name will be used in further steps.<\/p>\n<h2 class=\"wp-block-heading\"><b>2. Create a Rest end Point,which we can access after deployment<\/b><\/h2>\n<p>Add following Rest endpoint in the project.We are adding this very basic endpoint,so that we can later test the application by hitting this endpoint after deployment.<\/p>\n<div>\n<div id=\"highlighter_42024\" class=\"syntaxhighlighter  java\">\n<table border=\"0\" cellspacing=\"0\" cellpadding=\"0\">\n<tbody>\n<tr>\n<td class=\"gutter\">\n<div class=\"line number1 index0 alt2\">01<\/div>\n<div class=\"line number2 index1 alt1\">02<\/div>\n<div class=\"line number3 index2 alt2\">03<\/div>\n<div class=\"line number4 index3 alt1\">04<\/div>\n<div class=\"line number5 index4 alt2\">05<\/div>\n<div class=\"line number6 index5 alt1\">06<\/div>\n<div class=\"line number7 index6 alt2\">07<\/div>\n<div class=\"line number8 index7 alt1\">08<\/div>\n<div class=\"line number9 index8 alt2\">09<\/div>\n<div class=\"line number10 index9 alt1\">10<\/div>\n<div class=\"line number11 index10 alt2\">11<\/div>\n<div class=\"line number12 index11 alt1\">12<\/div>\n<div class=\"line number13 index12 alt2\">13<\/div>\n<div class=\"line number14 index13 alt1\">14<\/div>\n<div class=\"line number15 index14 alt2\">15<\/div>\n<div class=\"line number16 index15 alt1\">16<\/div>\n<div class=\"line number17 index16 alt2\">17<\/div>\n<div class=\"line number18 index17 alt1\">18<\/div>\n<div class=\"line number19 index18 alt2\">19<\/div>\n<\/td>\n<td class=\"code\">\n<div class=\"container\">\n<div class=\"line number1 index0 alt2\"><code class=\"java keyword\">package<\/code> <code class=\"java plain\">com.blogspot.javasolutionsguide.springbootproject;<\/code><\/div>\n<div class=\"line number2 index1 alt1\">&nbsp;<\/div>\n<div class=\"line number3 index2 alt2\"><code class=\"java keyword\">import<\/code> <code class=\"java plain\">org.springframework.web.bind.annotation.GetMapping;<\/code><\/div>\n<div class=\"line number4 index3 alt1\"><code class=\"java keyword\">import<\/code> <code class=\"java plain\">org.springframework.web.bind.annotation.RequestMapping;<\/code><\/div>\n<div class=\"line number5 index4 alt2\"><code class=\"java keyword\">import<\/code> <code class=\"java plain\">org.springframework.web.bind.annotation.RestController;<\/code><\/div>\n<div class=\"line number6 index5 alt1\">&nbsp;<\/div>\n<div class=\"line number7 index6 alt2\"><code class=\"java preprocessor\">\/**<\/code><\/div>\n<div class=\"line number8 index7 alt1\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java preprocessor\">* @author JavaSolutionsGuide<\/code><\/div>\n<div class=\"line number9 index8 alt2\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java preprocessor\">*<\/code><\/div>\n<div class=\"line number10 index9 alt1\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java preprocessor\">*\/<\/code><\/div>\n<div class=\"line number11 index10 alt2\"><code class=\"java color1\">@RestController<\/code><\/div>\n<div class=\"line number12 index11 alt1\"><code class=\"java color1\">@RequestMapping<\/code><code class=\"java plain\">(value = <\/code><code class=\"java string\">\"\/api\"<\/code><code class=\"java plain\">)<\/code><\/div>\n<div class=\"line number13 index12 alt2\"><code class=\"java keyword\">public<\/code> <code class=\"java keyword\">class<\/code> <code class=\"java plain\">Hello {<\/code><\/div>\n<div class=\"line number14 index13 alt1\">&nbsp;<\/div>\n<div class=\"line number15 index14 alt2\"><code class=\"java color1\">@GetMapping<\/code><code class=\"java plain\">(value = <\/code><code class=\"java string\">\"\/v1\/data\"<\/code><code class=\"java plain\">)<\/code><\/div>\n<div class=\"line number16 index15 alt1\"><code class=\"java keyword\">public<\/code> <code class=\"java plain\">String sayHelloWorld() {<\/code><\/div>\n<div class=\"line number17 index16 alt2\"><code class=\"java spaces\">&nbsp;<\/code><code class=\"java keyword\">return<\/code> <code class=\"java string\">\"Hello JavaSolutionsGuide Readers\"<\/code><code class=\"java plain\">;<\/code><\/div>\n<div class=\"line number18 index17 alt1\"><code class=\"java plain\">}<\/code><\/div>\n<div class=\"line number19 index18 alt2\"><code class=\"java plain\">}<\/code><\/div>\n<\/div>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<h2 class=\"wp-block-heading\"><b>3. Launch an EC2 instance<\/b><\/h2>\n<p>I have written a detailed step by step tutorial which explains how to Launch an EC2 instance in AWS.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>Here is the Link. <a href=\"https:\/\/www.javacodegeeks.com\/2019\/09\/how-to-launch-an-ec2-instance-in-aws.html\" target=\"_blank\" rel=\"noreferrer noopener\" aria-label=\" (opens in a new tab)\">How to Launch an EC2 instance on AWS<\/a> <\/p>\n<h2 class=\"wp-block-heading\"><b>4. Copy our Spring Boot project from our&nbsp; local machine to EC2 instance<\/b><\/h2>\n<p>As we want to deploy our spring boot project on EC2,the code has to move to EC2 instance.So for<\/p>\n<p>copying code from your local machine to EC2 instance ,executing following command from the directory where your code is lying.<\/p>\n<p>scp -i \/Users\/Aakarsh\/downloads\/<br \/>EC2Keypair.pem&nbsp;\/Users\/Aakarsh\/Downloads\/springbootproject\/target\/springbootproject-0.0.1-SNAPSHOT.jar ec2-user@ec2-54-242-53-241.compute-1.amazonaws.com:~<\/p>\n<p><b>Syntax of scp looks like following<\/b><\/p>\n<p>scp -i &lt;path to pem file on local machine&gt; &lt;path to spring boot project or your deliverables&gt;&nbsp; user@remote host name : ~<\/p>\n<h3 class=\"wp-block-heading\">scp<\/h3>\n<p>You can read more on SCP at following link <a rel=\"noopener noreferrer\" href=\"https:\/\/en.wikipedia.org\/wiki\/Secure_copy\" target=\"_blank\">Secure Copy Protocol<\/a> <\/p>\n<h3 class=\"wp-block-heading\"><b>.pem File<\/b><\/h3>\n<p>When you launch an EC2 instance in AWS,you specify the key pair.You can specify an existing key pair or a new key pair that you create at the launch.At EC2 boot time,the public key content is placed on the instance in an entry within ~\/.ssh\/authorized keys.To log into your instance,you must specify the private key(.pem file) when you connect to the instance.<\/p>\n<h3 class=\"wp-block-heading\"><b>ec2-user<\/b><\/h3>\n<p>please note that each Linux instance launches with a default Linux system user account.The default user name is determined by the API that user specified when you launched the instance.For Amazon Linux 2 or Amazon Linux API,the user name is ec2-user.<\/p>\n<h3 class=\"wp-block-heading\"><b>Tilde sign(~)<\/b><\/h3>\n<p>~ represents the home directory of the remote EC2 system.<\/p>\n<h2 class=\"wp-block-heading\"><b>5. Connect to EC2 instance using SSH<\/b><\/h2>\n<p><b>&nbsp;&nbsp;<\/b>For connecting to EC2 instance ,you need to follow following instructions.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"533\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.48.50-PM.png\" alt=\"\" class=\"wp-image-98819\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.48.50-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.48.50-PM-300x250.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<p>These instructions you will get once you click on instances and then Connect button from following screen.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"145\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.49.35-PM.png\" alt=\"\" class=\"wp-image-98820\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.49.35-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.49.35-PM-300x68.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<p>This is how it looks like when you execute commands from your terminal and gets connected to ec2 instance.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"174\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.47.23-PM.png\" alt=\"\" class=\"wp-image-98821\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.47.23-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.47.23-PM-300x82.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<h2 class=\"wp-block-heading\"><b>6. Remove JDK 7 and install JDK 8 over EC2 instance<\/b><\/h2>\n<p>EC2 instance that I got from AMI has open jdk 7 by default.<\/p>\n<p>We can go ahead with JDK 7 as well ,but as I am using JDK most of the times now and compiled my project with jdk 8 only,so I removed JDK 7 and installed JDK 8.<\/p>\n<h3 class=\"wp-block-heading\">Command to&nbsp; remove JDK 7<\/h3>\n<p>sudo yum remove java-1.7.0-openjdk<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"400\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.52.06-PM.png\" alt=\"\" class=\"wp-image-98822\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.52.06-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.52.06-PM-300x188.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\"><b>Command to Install JDK 8<\/b><\/h3>\n<p>sudo yum install java-1.8.0<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"372\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.53.27-PM.png\" alt=\"\" class=\"wp-image-98823\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.53.27-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.53.27-PM-300x174.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"258\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.54.34-PM.png\" alt=\"\" class=\"wp-image-98824\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.54.34-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-9.54.34-PM-300x121.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\"><b>7. Execute the spring boot jar on EC2 instance<\/b><\/h3>\n<p>Execute following command<\/p>\n<p>java -jar springbootproject-0.0.1-SNAPSHOT.jar<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"141\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.03.50-PM.png\" alt=\"\" class=\"wp-image-98825\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.03.50-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.03.50-PM-300x66.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<h3 class=\"wp-block-heading\"><b>8. Make sure your Security group allows the inbound traffic from internet over port 8080 and using TCP protocol<\/b><\/h3>\n<p>Click on the instance in AWS console and check the security group associated with your instance<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"315\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.07.02-PM.png\" alt=\"\" class=\"wp-image-98826\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.07.02-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.07.02-PM-300x148.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<p>As we can see in above screenshot ,the security group attached with this EC2 instance is launch-wizard-1<\/p>\n<p>Now,as we open this security group,I have following entry,which as you can see that allows traffic from internet over port 22 only using SSH.Acatually this was the reason we were able to connect using SSH from our machine to this EC2 instance.If we remove this rule from here,SSh will not work<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"314\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.08.44-PM.png\" alt=\"\" class=\"wp-image-98827\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.08.44-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.08.44-PM-300x147.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<p>But now as we want to test our endpoint from browser(internet) using http protocol and our application needs to be accessed over port 8080.so there should be rule corresponding to that in security group.<\/p>\n<p>So,Let us go ahead and add a security group inbound rule<\/p>\n<figure class=\"wp-block-image\"><a href=\"https:\/\/1.bp.blogspot.com\/-Ro2FnKzNxkg\/XZEQT8fuyWI\/AAAAAAAANNM\/n82vOH7JelsqAEDbBbAulUFMax3ctSb8ACLcBGAsYHQ\/s1600\/Screen%2BShot%2B2019-09-29%2Bat%2B10.12.45%2BPM.png\"><img decoding=\"async\" src=\"https:\/\/1.bp.blogspot.com\/-Ro2FnKzNxkg\/XZEQT8fuyWI\/AAAAAAAANNM\/n82vOH7JelsqAEDbBbAulUFMax3ctSb8ACLcBGAsYHQ\/s640\/Screen%2BShot%2B2019-09-29%2Bat%2B10.12.45%2BPM.png\" alt=\"\"\/><\/a><\/figure>\n<p>Click on save and your new rule will be saved.Also you don&#8217;t need to restart your instance to take this security group rule effect.It will take effect immediately,once you save the rule.<\/p>\n<h3 class=\"wp-block-heading\"><b>9. Test the Application by hitting the endpoint URL from browser<\/b>&nbsp;<\/h3>\n<p>Hit the following URL from your browser<\/p>\n<p><a href=\"http:\/\/ec2-3-19-64-196.us-east-2.compute.amazonaws.com:8080\/api\/v1\/data\">http:\/\/ec2-3-19-64-196.us-east-2.compute.amazonaws.com:8080\/api\/v1\/data<\/a><\/p>\n<p>Here\u00a0 \u00a0 ec2-3-19-64-196.us-east-2.compute.amazonaws.com\u00a0is the public DNS of the EC2 instance.<\/p>\n<div class=\"wp-block-image\">\n<figure class=\"aligncenter\"><img decoding=\"async\" width=\"640\" height=\"221\" src=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.14.44-PM.png\" alt=\"\" class=\"wp-image-98828\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.14.44-PM.png 640w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2019\/09\/Screen-Shot-2019-09-29-at-10.14.44-PM-300x104.png 300w\" sizes=\"(max-width: 640px) 100vw, 640px\" \/><\/figure>\n<\/div>\n<p>So,as you can see we are able to see the response from our endpoint Successfully,which means springbootproject is deployed successfully and is executing as expected.<\/p>\n<p>That&#8217;s all for this tutorial.Thanks for reading .Also I am going to write more such tutorial on AWS in coming days.If you find this tutorial useful,don&#8217;t forget to subscribe to blog to not miss the update on latest blogs.<\/p>\n<div class=\"attribution\">\n<table>\n<tbody>\n<tr>\n<td>\n<p>Published on Java Code Geeks with permission by Gaurav Bhardwaj, partner at our <a href=\"\/\/www.javacodegeeks.com\/join-us\/jcg\/\" target=\"_blank\" rel=\"noopener noreferrer\">JCG program<\/a>. See the original article here: <a href=\"http:\/\/javasolutionsguide.blogspot.com\/2019\/09\/how-to-deploy-spring-boot-application.html\" target=\"_blank\" rel=\"noopener noreferrer\">How to deploy a Spring Boot Application on AWS EC2 instance<\/a><\/p>\n<p>Opinions expressed by Java Code Geeks contributors are their own.<\/p>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Hello Friends, In this tutorial,we will see how we can deploy a Spring Boot application over an AWS EC2 instance. Here are the steps we are going to perform. 1. Create a Spring Boot Project with Spring Boot Initialiser.2. Create a Rest end Point,which we can access after deployment3. Launch an EC2 instance4. Copy our &hellip;<\/p>\n","protected":false},"author":955,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[758,854],"class_list":["post-98807","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-aws","tag-spring-boot"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2019-10-01T07:00:45+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gaurav Bhardwaj\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gaurav Bhardwaj\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html\"},\"author\":{\"name\":\"Gaurav Bhardwaj\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/58bd3e1f6edc1bed6a6374fe9a34ca37\"},\"headline\":\"How to deploy a Spring Boot Application on AWS EC2 instance\",\"datePublished\":\"2019-10-01T07:00:45+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html\"},\"wordCount\":1032,\"commentCount\":7,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"AWS\",\"Spring Boot\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html\",\"name\":\"How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2019-10-01T07:00:45+00:00\",\"description\":\"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2019\\\/10\\\/deploy-spring-boot-application-aws-ec2-instance.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"How to deploy a Spring Boot Application on AWS EC2 instance\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/58bd3e1f6edc1bed6a6374fe9a34ca37\",\"name\":\"Gaurav Bhardwaj\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g\",\"caption\":\"Gaurav Bhardwaj\"},\"description\":\"Gaurav has done Masters in Computer Applications(MCA) and is working in Software development field for more than 10 years in Java\\\/J2EE technologies. He is currently working with one of top MNC. He has worked on various frameworks like Struts, Spring, Spring Boot, Angular JS, JSF, Velocity, iBatis, MyBatis, Hibernate, JUnit, Mockito, Dozzer. He likes to explore new technologies and share his thoughts by writing a technical blog. He is the founder of JavaSolutionsGuide.blogspot.com.\",\"sameAs\":[\"http:\\\/\\\/www.javasolutionsguide.blogspot.nl\\\/\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/gaurav-bhardwaj\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks","description":"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html","og_locale":"en_US","og_type":"article","og_title":"How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks","og_description":"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.","og_url":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2019-10-01T07:00:45+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Gaurav Bhardwaj","twitter_card":"summary_large_image","twitter_creator":"@javacodegeeks","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Gaurav Bhardwaj","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html"},"author":{"name":"Gaurav Bhardwaj","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/58bd3e1f6edc1bed6a6374fe9a34ca37"},"headline":"How to deploy a Spring Boot Application on AWS EC2 instance","datePublished":"2019-10-01T07:00:45+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html"},"wordCount":1032,"commentCount":7,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["AWS","Spring Boot"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html","url":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html","name":"How to deploy a Spring Boot Application on AWS EC2 instance - Java Code Geeks","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2019-10-01T07:00:45+00:00","description":"Interested to learn about Spring Boot Application? Check our article explaining how to deploy a Spring Boot application over an AWS EC2 instance.","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2019\/10\/deploy-spring-boot-application-aws-ec2-instance.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"How to deploy a Spring Boot Application on AWS EC2 instance"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/58bd3e1f6edc1bed6a6374fe9a34ca37","name":"Gaurav Bhardwaj","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/657921afcac1f1ddf98dfb349121a07b4dcc1d42d5bd277150cf3ed8156de723?s=96&d=mm&r=g","caption":"Gaurav Bhardwaj"},"description":"Gaurav has done Masters in Computer Applications(MCA) and is working in Software development field for more than 10 years in Java\/J2EE technologies. He is currently working with one of top MNC. He has worked on various frameworks like Struts, Spring, Spring Boot, Angular JS, JSF, Velocity, iBatis, MyBatis, Hibernate, JUnit, Mockito, Dozzer. He likes to explore new technologies and share his thoughts by writing a technical blog. He is the founder of JavaSolutionsGuide.blogspot.com.","sameAs":["http:\/\/www.javasolutionsguide.blogspot.nl\/"],"url":"https:\/\/www.javacodegeeks.com\/author\/gaurav-bhardwaj"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/955"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=98807"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/98807\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=98807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=98807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=98807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}