
👍Java Spring Boot & Microservice Realtime Project development CT👍
February 4, 2025 at 09:39 AM
*5 Tasks for today: 4Feb*
✅ 1. Get clear basic understanding of Framework & APIs.
✅ 2. Code Hello World API using Spring Boot.
✅ 3. Use ChatGPT to generate CalculationController with add, sub, mul methods
✅ 4. Experiment with your 1st Spring Boot app
✅ 5. Understand DNS mappings (Domain, IP, Port)
======================
*1. Get clear basic understanding of Framework & APIs.*
* Building web app using plan core java vs with technologies (servlets/jsps) vs frameworks(Spring/Spring boot)
* https://spring.io/
Spring used for building:
Microservices|Reactive|Cloud|Webapp|Serverless|Even driven|Batch.
* Spring Boot is given as a "Project" by Spring Team.
https://spring.io/projects/spring-boot
* Spring Boot is build on top of core Spring framework.
* Provides rapid application development.
* 2 major features of Spring Boot is "starters" & "autoconfiguration"
Clarity on APIs
* Understand that its mostly preferred to develop & deploy frontend(FE) app separately & backend(BE) app separately.
* FE connects with backend via APIs.
* The APIs on web environment are called as WebAPIs or Webservices.
* There are multiple standards of API development, REST, JsonRS, SOAP, gRPC, GraphQL.
* The commonly used one across multiple projects is RestAPIs.
===============================
*2. Code Hello World API using Spring Boot.*
* Setup Eclipse STS:
https://spring.io/tools
* Maven would be available along with your Eclipse installation
* Refer below quick start guide to build app.
https://spring.io/quickstart
* You don't need to know what the annotations are, or how to code these, just think logically, and build application & test it. Just make it work.
* Create your demo project from https://start.spring.io/
* Java, Maven, Spring Boot: 3.4.2, jar, java 17, Web dependency
* Download & extract the demo project into your local workspace folder.
* Launch IDE on the workspace /ws/ide
* Import the demo.zip using "Import Existing Maven Project"
* Create DemoController by taking reference from
https://spring.io/quickstart
* Use basic maven commands to run the spring boot application
clean, package, clean package, clean spring-boot:run
* Ensure "Tomcat started on port 8080" in console
Test the application from browser by below 2 urls:
http://localhost:8080/hello
http://localhost:8080/hello?name=Amazing
============================
*3. Use ChatGPT to generate CalculationController with add, sub, mul methods*
Just experiment with ChatGPT,
set code in IDE
test from browser
============================
*4. Experiment with your 1st Spring Boot app*
* Refer to the LIVE session for details actions.
Experiment & build confidence on all of below points:
* Try to start same demo app, 2 times. And check port error.
* Stop the previous demo app using terminate button from IDE.
* Stop the demo app using commands to identify which process occupies 8080, and then end the task. Use IDE
netstat -ano | findstr :8080
* Strongly under how below maps to the functional method that you write.
http://:/
* Write a PostMapping method & try to call from browser. Check error.
* Debug in browser, right click => inspect option, network tab. Check 405 error
* Setup Postman, to test Post method call.
* Explore "empty cache & hard reload" of browser
* Add devtools maven dependency to pom.xml. Your changes should reflect automatically.
* Add SonarQube support in your IDE.
=============================
*5. Understand DNS mappings (Domain, IP, Port)*
* In DNS, we map domain name to IP of server
* default port for http is 80, https is 443
* If you use http://google.com, it maps as
http://:80
* If you use https://google.com, it maps as
http://:443
* You can check which IPs are mapped to domain using nslookup
nslookup google.com