0% found this document useful (0 votes)
57 views8 pages

Spring Boot & AWS Deployment Guide

Uploaded by

Prasanta Agasti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
57 views8 pages

Spring Boot & AWS Deployment Guide

Uploaded by

Prasanta Agasti
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

DIAGRAMS

LIVE NOTES:

Hi Team,

We will start in couple of minutes.

Please update this poll, regarding your yesterday's 1st app setup.

will start at 10:00.

IMPORTANT topic today!!!

========
14+ years...

Work on coding daily.. hand's on practical knowledge

Daily tasks would be updated to same form.


rededit same form daily.

Mark as DONE, only when you are confident, you can explain during interview.

============================

Web application
+ additional code (Spring Boot)
java

[Link]

Maven

Imported to IDE

1) clean package
=> .jar / .war

2) clean spring-boot:run
rt click => run as "Spring Boot App"

3) [Link]
[Link]

4) static/[Link]

======

5) browser caches your responses..


inspect browser, then long press refresh,
"Empty cache & hard reload"
incognito mode.

6) Create application via IDE

- close project

- Change Java version to JDK17


install oracle java, windows => preferences
install jre & complier session

- Instead of localhost, make it [Link]


[Link]
.2, .3..

- Default port is 8080, how to change

Can it be done?
How to do it??

8081

GitHub Copilot

"Pair programming with AI"


use internet

[Link]

How chatgpt & show github copilot

- API, where 2 applications can talk to each other


REST APIs standards

add 2 numbers..

write a rest api in spring boot, which takes 2 numbers & returns the sum.

- How to write Rest API to add to numbers & return in response


Use ChatGPT
Test from browser.

- Browser by default passes GET


accordingly in server some GetMapping should be available. Else server fails with
exception "Request method 'GET' is not supported"

- HTTP Verbs: GET, POST, PUT, DELETE....

- Tools for API testing.


- PostMan
Postman demo, and invoking via postman

- CURL command there in command prompt - demo that


curl -X POST "[Link]

- using AI + eclipse rtclick => refactor => extract local variable.

- For every change.. We are supposed to restart, then only applicable..

Maven dependency called dev-tools

[Link]
take dependency configuration, and add to [Link]
avoid using version wherever possible. Then maven will use corresponding
spring boot version, and take compatible dependency.

clean package

- Sonar - static code analyser.


You need to explicity add sonar configuration in your IDE.. for getting suggestions for
best practices of coding..
Help => Eclipse MarketPlace => sonarlint
windows => show view => sonarlint - on-the-fly

- How to use Loggers instead of S.o.p

Spring Boot - default: SLF4j => logback


private static final Logger logger = [Link]([Link]);

[Link]("Calculated sum: {}", sum);

----------------

Working with AWS.

We want to run our spring boot application in AWS, so other world can also access it..

AWS
EC2 machine
ECS
Severless

=====
1. Create AWS account
2. Create EC2 machine
3. Install Java 17
4. Copy code from your local machine to AWS EC2
5. Start your service in AWS
6. Access from local & test, if its working.

=====

1. Create AWS account - Mumbai


[Link]

2. Create EC2 machine - with key-pair


D:\ctdata\aws\[Link]

3. Install Java 17
connect to that machine.

Built in terminal - mac / ubuntu


windows - MobaXterm (we an connect to other machines & perform operation)

Connect to that EC2 machine


ssh -i D:\\ctdata\\aws\\[Link] ec2-user@[Link]

Should have basic Linux knowledge.

Install Java 17
sudo su
yum update
yum install java-17-amazon-corretto-17.0.10+7-1.amzn2.1.x86_64

java --version

4. Copy code from your local machine to AWS EC2


clean package
=> jar

copy jar file to destination EC2

scp <source> <destination>


scp -i D:\\ctdata\\aws\\[Link] ./[Link]
ec2-user@[Link]:/home/ec2-user

on AWS, if you want to override previous file, then use


chmod 777 *

then from local machine, do "SCP" again

5. Start your service in AWS

executable jar files.

javac
java

java -jar [Link]

6. Access from local & test, if its working.


AWS - Security group (inbound)
which ports are allowed to be accessed

For this EC2, in security group(inbound), enable 8081 to be accessed from outside.

ssh & scp (22 port)

ps -ef | grep java


what all java processes are running in this machine.

ps -ef

grep java

kill -9 14724

java -jar [Link]


as a back ground process

nohup <command> &


where the output logs will be written???

nohup java -jar -Xms100M -Xmx150M [Link] > [Link] &


tail -f [Link]

How to test in local.. and practice the way it will work in AWS...
----------------

=================================
1. Create AWS account - NA
2. Create EC2 machine - NA
3. Install Java 17 - INstall
4. Copy code from your local machine to AWS EC2

1. create jar file


2. scp -I <src> <desc> - AWS

for local:
1. create jar file
2. cp <src> <desc>

Destination folder:
D:\ctws\nov24ct\aws-deploy-testing

5. Start your service in AWS

java -jar [Link]

6. Access from local & test, if its working.


nohup java -jar -Xms100M -Xmx150M [Link] > [Link] &
tail -f [Link]
netstat -aon | findstr :8081 -------- (For Windows in mobaxterm)
kill -9 <pid>

relate with your local

You might also like