Рет қаралды 2,689
Web application....
Accessible over internet.
Java - core java, adv java
Build a web application, which can be assible over internet.
Client:
web applicaiton, so we can do business
develop functional application
Something readmade, easy to apply, which converts java application into an web application.
Web frameworks.
Spring Boot.
Microservice architecture
I want to run end-to-end web application using Spring Boot.
jdbc...
"
core java...
+
jar file provided by ojdbc.jar,
"
classpath
database oracle/mysql
Spring boot:
50+ jar file
100+ jar file
Dependencies:
abc.jar
200 java classes
pqr.jar
xyz.jar
tool/software
Build tools.
We would use Maven as a build tool, to add all spring boot dependencies to our java applicaiton. And transform it into web application.
A.java
compile
execute
javac A.java
java A
by executable jar file.
myjar.jar ... .war
A.class
java -jar myjar.jar
creation of executable jar. Using Maven
maven commands
mvn package
=] myapp.jar
java -jar myapp.jar
Start tomcat
run our web applicaiton here.
you can execute web applicaiton in webserver - httpserver
IDE: Eclipse STS
Java 17
Maven
1. Building Spring Boot application
2. run it locally & test
3. Setting up in AWS & execute there.
Mandatory server.
By Default, we would give you embeded tomcat in your spring boot application.
start.spring.io/
fill up data.
Add dependency: WEB.
Group:
Which company is developing that project.
accenture.com (Client)
group: com.accenture
com.google
Generate readmade project code.
myapp.zip
-------
IDE:
D:\mar24ct-workspace
Include the generate project into IDE.
MAVEN Project.
maven configuration: pom.xml
IDE Import.
Basic maven commands
mvn clean
mvn install =] new depedency
mvn package =] jar
mvn clean package
deleted existing
complied java classes
Created new jar file (target)
How to execute these commands from IDE.
rt click project =] Run As =] Maven build...
popup:
Goal:
Execute (Embeded Tomcat)
How do you run/execture it in local machine
mvn clean spring-boot:run - web applicaiton came up and its running on 8080 port.
Tomcat started on port 8080
Default port for Spring Boot.
How do you access it?
Browser.
8080
What should be my brower url.
localhost:8080/
127.0.0.1:8080/
127.0.0.1 | 127.255.255.254
3rd way:
ipconfig - public ip of your machine
IPv4 Address:
172.17.48.1:8080/
[machine ip where code is running]:[port]
Default port is 8080 - change it to 8081
2 services cannot run on same port.
Either you start it on another port.
or you kill existing service, & start new service on that port.
Identify and stop the process that's listening on port 8081 or configure this application to listen on another port.
How do you deploy & give to the real world.
-----
Infra: Cloud infra - AWS
myapp.jar
deploy this in AWS EC2 service
1. In AWS setup & start EC2
2. Do deployment in EC2.
Local myapp.jar =] AWS.
3. Mobaxterm []
connect to AWS EC2 - ssh
copy Local myapp.jar =] AWS. "scp"
terminal
basic linux command
scp ./jarfilename.jar ec2-user@43.205.240.11:/home/ec2-user
ssh ec2-user@43.205.240.11
nohup java -jar -Xms100M -Xmx150M myapp-0.0.1-SNAPSHOT.jar ] firstspring-0.0.1.jar.log &
Tomcat started on port 8080