<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Prasanth</title>
    <description>The latest articles on Forem by Prasanth (@prasanth362k).</description>
    <link>https://forem.com/prasanth362k</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2969391%2F1c84f204-47bf-437d-b68d-60b3e3321fbf.jpg</url>
      <title>Forem: Prasanth</title>
      <link>https://forem.com/prasanth362k</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/prasanth362k"/>
    <language>en</language>
    <item>
      <title>Building a Weather Application with Spring Boot and OpenWeatherMap API</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sat, 26 Jul 2025 14:32:02 +0000</pubDate>
      <link>https://forem.com/prasanth362k/building-a-weather-application-with-spring-boot-and-openweathermap-api-4323</link>
      <guid>https://forem.com/prasanth362k/building-a-weather-application-with-spring-boot-and-openweathermap-api-4323</guid>
      <description>&lt;ul&gt;
&lt;li&gt;Build a simple Weather App using Spring Boot, the OpenWeatherMap API, and Thymeleaf as the front-end template engine. Users can enter a city name, and the application will fetch and display current weather details.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;To get Api and APIKeys from “&lt;a href="https://home.openweathermap.org/%E2%80%9C" rel="noopener noreferrer"&gt;https://home.openweathermap.org/“&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;After signup/login&lt;/li&gt;
&lt;li&gt;Get APIKey from “&lt;a href="https://home.openweathermap.org/api_keys%E2%80%9C" rel="noopener noreferrer"&gt;https://home.openweathermap.org/api_keys“&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Get APIURL: “&lt;a href="https://api.openweathermap.org/data/2.5/weather?q=%7Bcity" rel="noopener noreferrer"&gt;https://api.openweathermap.org/data/2.5/weather?q={city&lt;/a&gt; name}&amp;amp;appid={API key}“&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;u&gt;example:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://api.openweathermap.org/data/2.5/weather?q=Thiruvallur&amp;amp;appid=93c30d18b6d15d780cc94b291984ad88" rel="noopener noreferrer"&gt;https://api.openweathermap.org/data/2.5/weather?q=Thiruvallur&amp;amp;appid=93c30d18b6d15d780cc94b291984ad88&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Weather Response:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you  get response in JSON data format &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Note:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;JSON response came from API call , now we need return the response to  now created project.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we want to  read to json data ,but we do not know  how to write program , Don  worry  we need to add dependencies , that one is  Jackason DataBind (Jackson Databind is a Java library that allows you to easily convert (bind) JSON data to Java objects and vice versa.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Main Use of Jackson Databind:-&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Read JSON =&amp;gt; Java Object (Deserialization)&lt;/li&gt;
&lt;li&gt;    Write Java Object =&amp;gt; JSON (Serialization)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Link:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.19.2" rel="noopener noreferrer"&gt;https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind/2.19.2&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;copy dependencies and paste  to you pom.xml &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;one website (you app or website) can get data from  another website  (open weather)  using public ApI, This is Apis work. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1. Overall Project Flow&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Request-Response Flow:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;User =&amp;gt;  Enters City in Form (HTML) =&amp;gt;  Controller =&amp;gt; Service =&amp;gt; OpenWeatherMap API&lt;br&gt;
     &amp;lt;= Response =&amp;gt; Data sent to View via Model =&amp;gt; Weather Displayed on Web Page&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.WeatherResponse.java (Model Layer)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Purpose:&lt;/u&gt; maps the Api Response  to java objects using jackson.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Contains:&lt;/u&gt;    &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; name = city name&lt;/li&gt;
&lt;li&gt; main = temperature, humidity, etc.&lt;/li&gt;
&lt;li&gt; weather[] = an array of weather descriptions
@JsonIgnoreProperties(ignoreUnknown = true) , ensure  that any unnecesary Json fields.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;



import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
// we need particular  JSON data another data ignore

@JsonIgnoreProperties(ignoreUnknown = true)
public class WeatherResponse {
    // only need those response  from like https://api.openweathermap.org/data/2.5/weather?q=Thiruvallur&amp;amp;appid=93c30d18b6d15d780cc94b291984ad88

    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public Main getMain() {
        return main;
    }
    public void setMain(Main main) {
        this.main = main;
    }
    public Weather[] getWeather() {
        return weather;
    }
    public void setWeather(Weather[] weather) {
        this.weather = weather;
    }
    private  String name ;
    private  Main main ;  // Main class
    private  Weather[] weather;  // weather class for array 


}
// we want to use this response this class only that why private (like one time usage)  and that why we create  above the class's in same class
class  Main 
{
    private double temp;
    private int humidity;
    private  int  sea_level;
    private   int pressure ;
    public double getTemp() {
        return temp;
    }
    public void setTemp(double temp) {
        this.temp = temp;
    }

    public int getHumidity() {
        return humidity;
    }
    public void setHumidity(int humidity) {
        this.humidity = humidity;
    }
    public int getSea_level() {
        return sea_level;
    }
    public void setSea_level(int sea_level) {
        this.sea_level = sea_level;
    }
    public int getPressure() {
        return pressure;
    }
    public void setPressure(int pressure) {
        this.pressure = pressure;
    }
    public int getGrnd_level() {
        return grnd_level;
    }
    public void setGrnd_level(int grnd_level) {
        this.grnd_level = grnd_level;
    }
    private int grnd_level; 


}
class  Weather
{
    private  String  description;

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    } 

}
// now we  done json object  convert  to java object


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;strong&gt;3.WeatherController.java (Controller Layer)&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controller  handles the  web API request.&lt;/li&gt;
&lt;li&gt;Calls the service to get weather data.&lt;/li&gt;
&lt;li&gt;Sends the data to the view using Model.
&lt;code&gt;model.addAttribute("weather", weatherResponse);
&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class WeatherController {   
    @Autowired
    private  WeatherService weatherService; 
    @GetMapping("/")
    public String  display()
    {

        return "weather";

    }

    // now to create src/main/resource create weather.html under templates 
    @GetMapping("/weather")
    public String show_weather_details(@RequestParam String  city , Model model)
    {
        // @RequestParam  get data from the URL 
        /*    Example: If URL is http://localhost:8080/weather?city=Chennai
         *  Then city will have the value "Chennai"
      It reads the ?city=Chennai part from the URL.
         * Model model
         * it is used  to store data that you want to send to the HTML(Thymleaf) page
         * like Model is used to store and pass data from the controller to the view (HTML
         * 
         */

        /* now  Below  this thing  , to implement  to code to service class. 
         * Api key  ,we already defined application  properties.
         * City
         * APIURL
         * weather responce 
         * 
         */
        WeatherResponse weatherResponse =   weatherService.getWeather(city); // 7 
    model.addAttribute("weather", weatherResponse);
    return  "weather" ;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;** 4. WeatherService.java (Service Layer)**&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;u&gt;Purpose:&lt;/u&gt; Make the Rest Api call to OpenWeathermap using RestTemplate.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Uses:&lt;/u&gt;&lt;br&gt;
&lt;code&gt;return restTemplate.getForObject(APIURL, WeatherResponse.class, city, apiKey);&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Uses @Value("${weather.api.key}") to inject the API key from application.properties
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;



import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

@Service
public class WeatherService {

//   Api key  ,we already defined application  properties   
    @Value("${weather.api.key}") // get the value in application properties
    private String  apiKey;
    //   * APIURL
    private final String APIURL = "https://api.openweathermap.org/data/2.5/weather?q={city}&amp;amp;appid={apiKey}";


    public WeatherResponse getWeather  (String city)
    {
    RestTemplate restTemplate = new RestTemplate();
 return restTemplate.getForObject(APIURL,WeatherResponse.class,city,apiKey); // 5
    //   * weather response 
    //How to  API Response data (Like weather data) get into to   browser page (htmlpage ), That one is  RestTemplate . 
   // Now we return APIURL,WeatherResponce.class(pojo class) ,city,apiKey with used to RestTemplate , to WeatherResponce class  .
    // now we connect to controller and response class  go to  controller class
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;5.Apllication properties&lt;br&gt;
&lt;code&gt;weather.api.key=YOUR_API_KEY_HERE&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;6.weather.html (View Layer - Thymeleaf)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;meta charset="UTF-8"&amp;gt;
    &amp;lt;title&amp;gt;Weather App&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            font-family: Arial, sans-serif;
            background: linear-gradient(to right, #83a4d4, #b6fbff);
            color: #333;
            padding: 20px;
            text-align: center;
        }

        .weather-box {
            background-color: white;
            border-radius: 10px;
            padding: 30px;
            max-width: 400px;
            margin: 30px auto;
            box-shadow: 0 0 10px rgba(0,0,0,0.2);
        }

        input[type="text"] {
            padding: 10px;
            width: 60%;
            border: 1px solid #ccc;
            border-radius: 5px;
            margin-top: 20px;
        }

        button {
            padding: 10px 20px;
            border: none;
            background-color: #007BFF;
            color: white;
            border-radius: 5px;
            margin-left: 10px;
            cursor: pointer;
        }

        button:hover {
            background-color: #0056b3;
        }

        .info {
            margin-top: 20px;
        }

        .error {
            color: red;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;

    &amp;lt;h1&amp;gt;🌦 Weather Application&amp;lt;/h1&amp;gt;

    &amp;lt;form action="/weather" method="get"&amp;gt;
        &amp;lt;input type="text" name="city" placeholder="Enter city name" required&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Search&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;

    &amp;lt;!-- Weather Result Section --&amp;gt;
    &amp;lt;div class="weather-box" th:if="${weather != null}"&amp;gt;
        &amp;lt;h2 th:text="${weather.name}"&amp;gt;City Name&amp;lt;/h2&amp;gt;
        &amp;lt;p class="info"&amp;gt;🌡 Temperature: &amp;lt;span th:text="${weather.main.temp}"&amp;gt;&amp;lt;/span&amp;gt; °C&amp;lt;/p&amp;gt;
        &amp;lt;p class="info"&amp;gt;💧 Humidity: &amp;lt;span th:text="${weather.main.humidity}"&amp;gt;&amp;lt;/span&amp;gt;%&amp;lt;/p&amp;gt;
        &amp;lt;p class="info"&amp;gt;🌤 Condition: &amp;lt;span th:text="${weather.weather[0].description}"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

    &amp;lt;!-- Show message if weather not found or city not entered --&amp;gt;
    &amp;lt;div th:if="${weather == null}"&amp;gt;
        &amp;lt;p class="error"&amp;gt;No weather data available. Please enter a valid city.&amp;lt;/p&amp;gt;
    &amp;lt;/div&amp;gt;

&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;


  &amp;lt;!-- when you submit  that button it trigger the  weather  action ,  now back to controller class --&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Final Results:- &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febza643e7h140th9z30n.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Febza643e7h140th9z30n.png" alt=" " width="800" height="556"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>java</category>
      <category>weatherapplication</category>
    </item>
    <item>
      <title>To do List App - SprinBoot</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sun, 13 Jul 2025 06:47:39 +0000</pubDate>
      <link>https://forem.com/prasanth362k/to-do-list-app-sprinboot-21lo</link>
      <guid>https://forem.com/prasanth362k/to-do-list-app-sprinboot-21lo</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;u&gt;Step:1&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
File -&amp;gt; String Starter Project -&amp;gt; Project name ToDoList -&amp;gt;Type Maven -&amp;gt; Packaging Jar-&amp;gt; Next&lt;br&gt;
&lt;u&gt;&lt;strong&gt;Step:2&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
&lt;u&gt;Add dependencies:-&lt;/u&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Spring Web&lt;/li&gt;
&lt;li&gt; Spring Dev Tools&lt;/li&gt;
&lt;li&gt; Thymeleaf &lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;u&gt;Step:2-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;create class ToDoController, at the top of class @Controller and @RequestMapping("/todo") and method &lt;br&gt;
for @GetMapping. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@GetMapping  is handle HTTP Get request coming from frontend or Postman , or any api clients.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;it is a shortcut for  @RequestMapping(method = RequestMethod.GET). it used to method level  inside a controller class to map  a specific URL to a method(function).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@RequestMapping("/todo")@RequestMapping is general -purpose annotation used to handle any type of HTTP request(GET,POST,PUT,kDELETE) depends on method the attributes.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;BY short HttpSession to handle the every user session data temporarily without database,not only one page across every page. without HttpSession do not remember your web site, , session memory erased(session not remember you) when you log out or browser closed , because is temp  memory.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Controller class Explanation:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allready you know that Controller is handles for HTTP web requests or  REST API request and also resposbile for returning views(HTML pages) via Thymeleaf of JSP. @RequestMapping("/todo") .Maps the base URL path /todo  to the controller.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In Controller class  all method base path is  /todo.so when a request is send to &lt;a href="http://localhost:8080/todo" rel="noopener noreferrer"&gt;http://localhost:8080/todo&lt;/a&gt;, this controller is responsible and  handle it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Method: show_todo_list(...)@Getmapping handle Http GEt requests.now we can not specified any path so ,the base path is /todo/  like GET/todo&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;,if any you set the path like @Getmapping("/show_todo") that time is you can  &lt;a href="http://localhost:8080/todo/show_todo" rel="noopener noreferrer"&gt;http://localhost:8080/todo/show_todo&lt;/a&gt; ,to HTTP GET request. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Parameters: Model model, HttpSession session&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Model  is used to send data form controller to view,Attributes added to the model will be avilabel int Thymelaf HTML page(like todo.html) 
** HttpSession ?**&lt;/li&gt;
&lt;li&gt;HttpSession store data per every user across multiple multiple HTTP requests. it holds the task list of every user. every use get unique session ,so their task not mixed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;blog link :- &lt;a href="https://dev.to/prasanth362k/httpsession-21g2"&gt;https://dev.to/prasanth362k/httpsession-21g2&lt;/a&gt;&lt;br&gt;
&lt;strong&gt;Logic in the Method:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt; List&amp;lt;String&amp;gt; tasks = (List&amp;lt;String&amp;gt;) session.getAttribute("tasks");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;session.getAttribute("tasks"); =&amp;gt;  it retrives the object  stored to session under the key "tasks".this return type for object . now need except list tasks (string value) so we can typecast (List) ,because session.getAttribute("tasks"); it returns object , not returns specfic type.,we store List of tasks(string) to the tasks like List tasks = &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Condition Check:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if (tasks == null) {
    tasks = new ArrayList&amp;lt;String&amp;gt;();
    session.setAttribute("tasks", tasks);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;If no tasks list was found  the session is  null .so the new list create new ArrayList(),the list stored  to tasks variable ,then list saved into the session with key ""tasks"&lt;/li&gt;
&lt;li&gt;add to Model&lt;/li&gt;
&lt;li&gt;model.addAttribute("tasks", tasks);&lt;/li&gt;
&lt;li&gt;this adds the tasks list model,model is a Spring object used to send data from controller to HTML view (Thymeleaf). So in todo.html, you can access this list using ${tasks}.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Before project  Model was used to hold data int he controller  and send it to the HTML  (Thymeleaf) view page. Now HttpSession is used to store user-specific data, and Model is still used to send that data to the view page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;model.addAttribute("tasks", tasks);
        return "todo";
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This line  sends the tasks data (like a list of tasks)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;from  the java back end  to the Html page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;tasks is the java variable that has the list of tasks."tasks" is the name used  in html page to get the data.return "todo"; this line tells spring boot ,show the todo.html  page and give it the data ,i added data  to model.  &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note: Other methods  explained simply  inside controller class&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step:3&lt;/strong&gt;&lt;br&gt;
create Html file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;

&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;TODO List&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;

&amp;lt;body&amp;gt;
    &amp;lt;h2&amp;gt;ToDo List - Spring Boot App&amp;lt;/h2&amp;gt;
    &amp;lt;!--  Add new TOdo --&amp;gt;

    &amp;lt;form action="/todo/add" method="post"&amp;gt;
        &amp;lt;input type="text" name="task" required placeholder="Enter Task"&amp;gt;
        &amp;lt;button type="submit"&amp;gt;Add&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
    &amp;lt;!-- Displaying All ToDo Tasks --&amp;gt;
    &amp;lt;ul&amp;gt;
        &amp;lt;li th:each="task, iterStat:${tasks}"&amp;gt;
            &amp;lt;span th:text="${task}"&amp;gt; &amp;lt;/span&amp;gt;

            &amp;lt;!-- Displaying All ToDo Tasks --&amp;gt;
            &amp;lt;form action="/todo/delete" method="post"&amp;gt;
                &amp;lt;input type="hidden" name="index" th:value="${iterStat.index}"&amp;gt;
                &amp;lt;!-- &amp;lt;input
    type="hidden"                  Hidden field: user can't see or edit this 
    name="index"                   The name of the field to be sent in form 
    th:value="${iterStat.index}"  Thymeleaf expression: gives current index in loop
     --&amp;gt;
                &amp;lt;button type="submit"&amp;gt; Delete &amp;lt;/button&amp;gt;
            &amp;lt;/form&amp;gt;

        &amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;

    &amp;lt;form action="/todo/delete_all" method="post"&amp;gt;
        &amp;lt;button type="submit"&amp;gt; Delete All &amp;lt;/button&amp;gt;

    &amp;lt;/form&amp;gt;


&amp;lt;/body&amp;gt;

&amp;lt;/html&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Step:4&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;create Controller class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import jakarta.servlet.http.HttpSession;

@Controller
@RequestMapping("/todo")//loczlhost:8080/todo
public class ToDoController {

    @GetMapping
    public String show_todo_list(Model model,HttpSession session)
    {
        List&amp;lt;String&amp;gt; tasks  = (List&amp;lt;String&amp;gt;)session.getAttribute("tasks");

        if(tasks == null)
        {
            tasks = new ArrayList&amp;lt;String&amp;gt;();
            session.setAttribute("tasks", tasks);
        }
        model.addAttribute("tasks", tasks);
        return "todo";
    }
    @PostMapping("/add") // when you  add some task  that request came to this method from ,request came from html .
    public String add_todo(@RequestParam String task ,HttpSession session)
    {
/*
 *  Why http://localhost:8080/todo/add does not work directly in the browser:
 * Post request mean like form submission 
 *  http://localhost:8080/todo/add, it sends a GET request , You will get an error like 405 Method Not Allowed or Whitelabel error page.
 * 
 * 
        */
       // @RequestParam String task means   get  the value or data of task from the URL form(sent from frontend), the data passed to the backend , you can  use to store  the data , not avilable closes browser or session ends
        // String task ,HttpSession session it mean  user give task , we will maintain  session .
        List&amp;lt;String&amp;gt; tasks  = (List&amp;lt;String&amp;gt;)session.getAttribute("tasks");

        if(tasks == null)
        {
            tasks = new ArrayList&amp;lt;String&amp;gt;();
            session.setAttribute("tasks", tasks);
        }
        tasks.add(task);
        return "redirect:/todo"; // redirect same page 
        // this code add  task but do not display , you can write code in  html . 
    }
    @PostMapping("/delete") // when you  delete some task  that request came to this method from ,request came from html(web page) .
    public String delete_todo(@RequestParam int index ,HttpSession session)
    {
        List&amp;lt;String&amp;gt; tasks  = (List&amp;lt;String&amp;gt;)session.getAttribute("tasks");
        tasks.remove(index);
        return "redirect:/todo"; // redirect same page 



        }
    @PostMapping("/delete_all")
    public String deleteAll(HttpSession session) // now only session maintain not  is requestparam that why we use to session 
    {   
        session.removeAttribute("tasks");
        return "redirect:/todo"; // redirect same page 

    }
    // now we did todo list with   (temp data)  session management  without using  database

}


// @RequestParam int index    gets the tasks's index number from the URL or Form like 0,1,2.
tasks.remove(index) remove the taks at tha index from the list .


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>spring</category>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
    </item>
    <item>
      <title>HttpSession</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sun, 06 Jul 2025 07:48:12 +0000</pubDate>
      <link>https://forem.com/prasanth362k/httpsession-21g2</link>
      <guid>https://forem.com/prasanth362k/httpsession-21g2</guid>
      <description>&lt;h3&gt;
  
  
  What is HttpSession?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;HttpSession is a part of Java’s Servlet API that helps a web application temporarily store and remember user-specific data (like name, email, role, etc.) across multiple requests (pages).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Httpsession is used store data per user across multiple Http request(like web app remember a user's data while they move between pages)&lt;br&gt;
.it  helps for spring boot   remember  a user between requests/pages  like a temporary memory for each logged in user.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Httpsession  is interface ,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;memory Location: server side&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Timeout duration: Default  30 min &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store format:key-value(string-object)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-life usage:Login.cart,dashboard,preferences.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;when user login in , you can store their name in the session:&lt;br&gt;
&lt;code&gt;session.setAttribute("key", value);&lt;br&gt;
session.setAttribute("username", "Prasanth");&lt;/code&gt;&lt;br&gt;
Later, another method ,you can get it back:&lt;br&gt;
&lt;code&gt;String name = (String) session.getAttribute("username");&lt;br&gt;
session.getAttribute("key");&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Even though user movers between pages, their name stays stored in the session , until that user log out or session expires.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;why to use HttpSession?&lt;/strong&gt; &lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Because Http is stateless -&amp;gt; like by default , each  request does not remember anything about previous ones. &lt;br&gt;
so we use HttpSession  to: &lt;br&gt;
&lt;u&gt;useCase:-&lt;/u&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;user login  -&amp;gt; keep user info save across pages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;shoppig cart -&amp;gt; store selected item temporarily. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;preference    -&amp;gt; store user setting ,them,laguage&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Prevent re-login  -&amp;gt; Avoid asking for details again and agian. &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt; &lt;strong&gt;Why HttpSession Is Useful?&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Avoids using database for every small detail&lt;/li&gt;
&lt;li&gt;  Works even if user switches pages&lt;/li&gt;
&lt;li&gt;  Fast, lightweight, temporary (auto clears after timeout)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;With Session?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You log in once, and your info is remembered until you:&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt; Logout Or close the browser Or session times out&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;u&gt;Stores data like:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; username&lt;/li&gt;
&lt;li&gt; user ID&lt;/li&gt;
&lt;li&gt; shopping cart&lt;/li&gt;
&lt;li&gt; user preference&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Without Session?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Every page would forget who you are.&lt;/li&gt;
&lt;li&gt;You’d have to log in again and again&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  You visit a login page → enter name → click login&lt;/li&gt;
&lt;li&gt;  The next page doesn't remember what you did earlier unless you store it (like using HttpSession)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;br&gt;
 Features of HttpSession:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Stores user data =&amp;gt;  Temporarily stores data for each user (e.g., login info, cart)&lt;/li&gt;
&lt;li&gt; Unique per user =&amp;gt; Each user gets a separate session&lt;/li&gt;
&lt;li&gt; Set &amp;amp; get values =&amp;gt;  You can store and retrieve values using setAttribute / getAttribute&lt;/li&gt;
&lt;li&gt; Auto session ID=&amp;gt;Automatically assigns a unique session ID to each user   Secure Can be configured to expire or invalidate when needed.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Where is it stored?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Data is stored on the server side (in RAM or temporary session storage)&lt;/li&gt;
&lt;li&gt;  Only the session ID is sent to the client (browser) via a cookie.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt; Duration of Session (Timeout)&lt;/u&gt;&lt;br&gt;
Type:-  &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Default timeout=&amp;gt;Usually 30 minutes (can be changed in configuration)&lt;/li&gt;
&lt;li&gt;Manually expired =&amp;gt;You can call session.invalidate(); to end the session
3.Configurable  Set time using session.setMaxInactiveInterval(600); // 10 min&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;strong&gt;Where it comes from?&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;HttpSession is an interface&lt;/p&gt;

&lt;p&gt;&lt;code&gt;Comes from the jakarta.servlet.http.HttpSession package&lt;br&gt;
(Earlier it was javax.servlet.http.HttpSession)&lt;/code&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;How to use it?&lt;/strong&gt;&lt;br&gt;
// Store data&lt;br&gt;
session.setAttribute("username", "Prasanth");&lt;/p&gt;

&lt;p&gt;// Get data&lt;br&gt;
String name = (String) session.getAttribute("username");&lt;/p&gt;

&lt;p&gt;// Remove data&lt;br&gt;
session.removeAttribute("username");&lt;/p&gt;

&lt;p&gt;// Invalidate session&lt;br&gt;
session.invalidate();&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Registration_Form</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sat, 05 Jul 2025 00:16:10 +0000</pubDate>
      <link>https://forem.com/prasanth362k/registrationform-3d6d</link>
      <guid>https://forem.com/prasanth362k/registrationform-3d6d</guid>
      <description>&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:1&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
File -&amp;gt; String Starter Project -&amp;gt; Project name Random_Quote_Generator -&amp;gt;Type Maven -&amp;gt; Packaging Jar-&amp;gt; Next&lt;br&gt;
&lt;u&gt;&lt;strong&gt;Step:2&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
&lt;u&gt;Add dependencies:-&lt;/u&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; Spring Web&lt;/li&gt;
&lt;li&gt; Spring Dev Tools&lt;/li&gt;
&lt;li&gt; Thymeleaf 
then finish.&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt; If unfortunately you not add missed some dependencies that time your project pom.xml (Right click)-spring -&amp;gt; ADD startes -&amp;gt; next -&amp;gt; you can add missed dependencies -&amp;gt; Next -&amp;gt; select pom.xml -&amp;gt; finish,&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;Step:3&lt;/u&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;create class Reg_Controller,create method,display,@GetMapping is used in a controller to handle HTTP GET requests.Model is an interface used in controller classes to store and pass objects (like List, String, .. etc)(data) to (Thymeleaf template)HTML view pages."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Now we add  multiple list of object (countries, gender, hobbies) into Model  using  object(model.addAttribute) and returned "home_page".List.of is  create a immutable/constant list(fixed -you can not add/remove elements later ,if you throw any error you can modify later)&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;

@Controller
public class Reg_Controller {

    @GetMapping("home")
    public String display(Model model)
    {

        model.addAttribute("Contreies",List.of("India","Pakistan","Srilanka"));
        model.addAttribute("Gender",List.of("Male","Female","Others"));
        model.addAttribute("Hobbies",List.of("Playing","Singing","Dancing"));

        return "home_page";

    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;&lt;strong&gt;step:4&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now create home_page.html  under the /src/main/resource/template/home_page.html
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Registration&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            background-color: #e6f0ff;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .form-container {
            background-color: white;
            padding: 30px;
            border-radius: 12px;
            border: 2px solid skyblue;
            box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
            width: 420px;
        }

        h2 {
            text-align: center;
            color: #2c3e50;
        }

        label {
            display: block;
            margin-top: 15px;
            font-weight: bold;
            text-align: left;
        }

        input[type="text"],
        input[type="email"],
        input[type="date"],
        select {
            width: 100%;
            padding: 10px;
            border-radius: 6px;
            border: 1px solid #ccc;
            margin-top: 5px;
        }

        .radio-group,
        .checkbox-group {
            display: flex;
            flex-wrap: wrap;
            gap: 10px;
            margin-top: 10px;
        }

        button {
            margin-top: 20px;
            width: 100%;
            padding: 12px;
            background-color: skyblue;
            border: none;
            border-radius: 8px;
            font-size: 16px;
            font-weight: bold;
            cursor: pointer;
        }

        button:hover {
            background-color: #5aa3e4;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div class="form-container"&amp;gt;
    &amp;lt;form action="/register" method="post"&amp;gt;
        &amp;lt;h2&amp;gt;Registration Form&amp;lt;/h2&amp;gt;

        &amp;lt;label&amp;gt;Name:&amp;lt;/label&amp;gt;
        &amp;lt;input type="text" name="username" required&amp;gt;

        &amp;lt;label&amp;gt;Email:&amp;lt;/label&amp;gt;
        &amp;lt;input type="email" name="email" required&amp;gt;

        &amp;lt;label&amp;gt;Gender:&amp;lt;/label&amp;gt;
        &amp;lt;div class="radio-group"&amp;gt;
            &amp;lt;th:block th:each="gender : ${Genders}"&amp;gt;
                &amp;lt;label&amp;gt;
                    &amp;lt;input type="radio" name="gender" th:value="${gender}"&amp;gt;
                    &amp;lt;span th:text="${gender}"&amp;gt;&amp;lt;/span&amp;gt;
                &amp;lt;/label&amp;gt;
            &amp;lt;/th:block&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;label&amp;gt;Country:&amp;lt;/label&amp;gt;
        &amp;lt;select name="country"&amp;gt;
            &amp;lt;option value=""&amp;gt;-- Select --&amp;lt;/option&amp;gt;
            &amp;lt;option th:each="country : ${Contreies}" th:value="${country}" th:text="${country}"&amp;gt;&amp;lt;/option&amp;gt;
        &amp;lt;/select&amp;gt;

        &amp;lt;label&amp;gt;Hobbies:&amp;lt;/label&amp;gt;
        &amp;lt;div class="checkbox-group"&amp;gt;
            &amp;lt;th:block th:each="hobby : ${Hobbies}"&amp;gt;
                &amp;lt;label&amp;gt;
                    &amp;lt;input type="checkbox" name="hobbies" th:value="${hobby}"&amp;gt;
                    &amp;lt;span th:text="${hobby}"&amp;gt;&amp;lt;/span&amp;gt;
                &amp;lt;/label&amp;gt;
            &amp;lt;/th:block&amp;gt;
        &amp;lt;/div&amp;gt;

        &amp;lt;label&amp;gt;Date of Birth:&amp;lt;/label&amp;gt;
        &amp;lt;input type="date" name="dob" required&amp;gt;

        &amp;lt;button type="submit"&amp;gt;Register&amp;lt;/button&amp;gt;
    &amp;lt;/form&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:5&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Now  past the url In browser &lt;a href="http://localhost:8080/home" rel="noopener noreferrer"&gt;http://localhost:8080/home&lt;/a&gt; , fill the contents the register form  ,you error came  ,  because  you wrote  this html file ,you get the value from server using @GetMapping("/home") ,but when register press button it trigger action to find post, you controller class not available @PostMapping and other related method so we will create @PostMapping and and other related method. by simple @GetMapping("/home"). to get the vale from server , @PostMapping("/register") Post mapping post value to server .
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@PostMapping("/register")
    public String get_details()
    {

        return "registered";

    }


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;&lt;p&gt;create registerd.html in src/main/resource/template.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;inside of html  just type  now only: &lt;br&gt;
Registration Successful.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Step:6&lt;/strong&gt;&lt;br&gt;
&lt;a href="http://localhost:8080/home" rel="noopener noreferrer"&gt;http://localhost:8080/home&lt;/a&gt; ,fill the Form , you see&lt;/p&gt;

&lt;p&gt;Registration Successful.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;step:7&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;@RequestParam is used to get values from and HTML form(frontend)home_page.html in to your Spring Boot controller(backedn), then now that values move to another HTML form(frontend) is registerd.html&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;How it works Like:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;1.you fill the form in web pages.&lt;br&gt;
2.when press register that data came controller method get_details(....) using POST(@PostMapping("/register"))&lt;br&gt;
3.Spring uses @RequesParm to grab values form the HTML input fields by their name attributes from html file, and store them in to  java variable(parameter in your method)&lt;/p&gt;

&lt;p&gt;html&lt;br&gt;
name attribute:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;input type="text" name="username"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
    @PostMapping("/register")
    public String get_details(
            @RequestParam String username,
            @RequestParam String gender,
            @RequestParam List&amp;lt;String&amp;gt; hobbies, Model model)
    {

        model.addAttribute("uname", username);
        model.addAttribute("gen", gender);
        model.addAttribute("hobbies", hobbies);
        return "registered";

    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;registered.html&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt;
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Success&amp;lt;/title&amp;gt;
    &amp;lt;style&amp;gt;
        body {
            background-color: #d9f2ff;
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            display: flex;
            justify-content: center;
            align-items: center;
            height: 100vh;
        }

        .success-box {
            background-color: white;
            border: 2px solid #7ac9f9;
            border-radius: 12px;
            padding: 30px;
            width: 450px;
            box-shadow: 0 0 12px rgba(0, 0, 0, 0.15);
        }

        h1 {
            color: #2b7bb9;
            text-align: center;
            margin-bottom: 20px;
        }

        h2 {
            font-size: 18px;
            color: #333;
            margin-bottom: 10px;
        }

        ul {
            list-style-type: circle;
            padding-left: 20px;
            text-align: left;
        }
    &amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div class="success-box"&amp;gt;
    &amp;lt;h1&amp;gt; Registration Successful!&amp;lt;/h1&amp;gt;

    &amp;lt;h2&amp;gt;Name: &amp;lt;span th:text="${uname}"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h2&amp;gt;
    &amp;lt;h2&amp;gt;Email: &amp;lt;span th:text="${email}"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h2&amp;gt;
    &amp;lt;h2&amp;gt;Gender: &amp;lt;span th:text="${gen}"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h2&amp;gt;
    &amp;lt;h2&amp;gt;Date of Birth: &amp;lt;span th:text="${dob}"&amp;gt;&amp;lt;/span&amp;gt;&amp;lt;/h2&amp;gt;

    &amp;lt;h2&amp;gt;Hobbies:&amp;lt;/h2&amp;gt;
    &amp;lt;ul&amp;gt;
        &amp;lt;li th:each="h : ${hobbies}" th:text="${h}"&amp;gt;&amp;lt;/li&amp;gt;
    &amp;lt;/ul&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;&lt;u&gt;class Reg_Controller &lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import java.util.List;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;

@Controller
public class Reg_Controller {

    @GetMapping("/home")
    public String display(Model model)
    {

        model.addAttribute("Contreies",List.of("India","Pakistan","Srilanka"));
        model.addAttribute("Genders",List.of("Male","Female","Others"));
        model.addAttribute("Hobbies",List.of("Playing","Singing","Dancing"));

        return "home_page";

    }
    @PostMapping("/register")
    public String get_details(
            @RequestParam String username,
            @RequestParam String email,
            @RequestParam String gender,
            @RequestParam String dob,
            @RequestParam List&amp;lt;String&amp;gt; hobbies, Model model)
    {

        model.addAttribute("uname", username);
        model.addAttribute("email", email);
        model.addAttribute("gen", gender);
        model.addAttribute("dob", dob);
        model.addAttribute("hobbies", hobbies);
        return "registered";

    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
    <item>
      <title>Random Quote Generator</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Fri, 04 Jul 2025 11:22:04 +0000</pubDate>
      <link>https://forem.com/prasanth362k/random-quote-generator-307n</link>
      <guid>https://forem.com/prasanth362k/random-quote-generator-307n</guid>
      <description>&lt;p&gt;&lt;strong&gt;Step:1&lt;/strong&gt;&lt;br&gt;
File -&amp;gt; String Starter Project -&amp;gt; Project name Random_Quote_Generator -&amp;gt;Type Maven -&amp;gt; Packaging Jar-&amp;gt; Next&lt;br&gt;
&lt;strong&gt;Step:2&lt;/strong&gt;&lt;br&gt;
&lt;u&gt;Add dependencies:-&lt;/u&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Spring Web&lt;/li&gt;
&lt;li&gt;Spring Dev Tools&lt;/li&gt;
&lt;li&gt;Thymeleaf
then finish.
If unfortunately  you not add missed some dependencies that time your project pom.xml (Right click)-spring -&amp;gt;  ADD startes -&amp;gt; next -&amp;gt; you can add missed dependencies -&amp;gt; Next -&amp;gt; select pom.xml -&amp;gt; finish,&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;spring web and Thymeleaf before we saw what and why,  now we see spring Dev Tool.&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  &lt;u&gt;What is Spring Boot DevTools?&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Spring Boot DevTools  is a development-ime tool that helps  developer save time and increase productivity by automatically reloading the application when code changes are made.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;work faster less effort,you do not need to stop and restart the app and again and again ,DevTool handle it , you can focus on writing code ,not managing the server.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;### Why to use Spring DevTools?&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automatic Restart -&amp;gt; Automatically restart the app when you change a class or file like home.html file.&lt;/li&gt;
&lt;li&gt;Live Reload -&amp;gt; Automatically refresh the browser when templates(html/Thymeleaf)change.&lt;/li&gt;
&lt;li&gt;Catching Disabled -&amp;gt; Disable template or static file catching during development.&lt;/li&gt;
&lt;li&gt;No need to Re-run -&amp;gt; you do not need to stop/start/ the app manually every time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:3&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
create QuoteService  class then add top of class @Service ,ctr+shift+o(import service)&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;step:4&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
create method:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public String show_quote()
    {
    //List&amp;lt;String&amp;gt; quoteList = new ArrayList&amp;lt;String&amp;gt;
    List&amp;lt;String&amp;gt; quoteList = List.of("Try Hard","Hard work never fails","Spend Time wisely","Practice brings Perfection");

    Random random = new Random();
    int random_no =random.nextInt(quoteList.size()); 
    return quoteList.get(random_no);
    }

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Why not used now this  line&lt;br&gt;
List&amp;lt;String&amp;gt; quoteList = new ArrayList&amp;lt;String&amp;gt;&lt;br&gt;
&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Creates a modifiable(not-fixed) list&lt;/li&gt;
&lt;li&gt;you can add, remove,update values.&lt;/li&gt;
&lt;li&gt;Used when list changes at runtime&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;code&gt;why used this line&lt;br&gt;
List&amp;lt;String&amp;gt; quoteList = List.of(....);&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;creates an unmodified(fixed) list&lt;/li&gt;
&lt;li&gt;you can not modify(add/remove) values.&lt;/li&gt;
&lt;li&gt;used when list constant/randomly changed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:5&lt;/strong&gt; &lt;/u&gt;Random is a class in Java (java.util.Random)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;it is used to generate the random numbers.Can be used to get: Random int,double,Boolean...etc.
nextInt is  generate random number from 0 to n-1 , when use  quoteList.size() ,it give random valid index list  like now  we have 3 list quoteList, random number from  0 to 2  , because random starts 0
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Random random = new Random();
    int num =random.nextInt(quoteList.size()); 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:6&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;create controller class QuotesController and we use dependence injection  , one of type for field(auto-wiring with @Autowired) not to create object,if you create object it lead to tightly couple.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@GetMapping is used in a controller to handle HTTP GET requests.Model is an interface used in controller classes to store and pass objects (like List, String, .. etc)(data) to (Thymeleaf template)HTML view pages."&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Thymeleaf is a template engine — it takes that Java data and dynamically renders(not fixed type value will change based on back end data or user input ) HTML content.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class QuotesController {

    @Autowired
    private QuoteService quoteService;

    @GetMapping("/quotesPage")
    public String  display_Quotes(Model model)
    {
        String quote = quoteService.show_quote();
        model.addAttribute("Proverb", quote);
        return "quotes_page";

    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;u&gt;&lt;strong&gt;Step:7&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Create quotes_page.html  in /src/main/resource/template/&lt;/p&gt;

&lt;p&gt;quotes_page.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html xmlns:th="http://www.thymeleaf.org"&amp;gt; 

&amp;lt;head&amp;gt;
&amp;lt;title&amp;gt; Random Quote Generator

&amp;lt;/title&amp;gt;  

&amp;lt;style&amp;gt;
div{
text-align: center;
}

&amp;lt;/style&amp;gt;
&amp;lt;head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;div&amp;gt;
&amp;lt;h2&amp;gt; Random Quote Generator&amp;lt;/h2&amp;gt;
&amp;lt;h3 th:text="${proverb}"&amp;gt; &amp;lt;/h3&amp;gt;
&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;class QuoteService&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import org.springframework.stereotype.Service;

@Service
public class QuoteService {
    public String show_quote()
    {
    //List&amp;lt;String&amp;gt; quoteList = new ArrayList&amp;lt;String&amp;gt;
    List&amp;lt;String&amp;gt; quoteList = List.of("Try Hard","Hard work never fails","Spend Time wisely","Practice brings Perfection");

    Random random = new Random();
    int random_no =random.nextInt(quoteList.size()); 
    return quoteList.get(random_no);
    }


}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;// List is interface ,Hold multiple values like array ,follow insertion order(first added item stays first, second stays second),allowed duplicate values,you can access element by index. &lt;/p&gt;

</description>
    </item>
    <item>
      <title>product catalogue</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Thu, 03 Jul 2025 13:33:18 +0000</pubDate>
      <link>https://forem.com/prasanth362k/product-catalogue-1n8</link>
      <guid>https://forem.com/prasanth362k/product-catalogue-1n8</guid>
      <description>&lt;p&gt;&lt;u&gt;Today we have to create product catalogue:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open Eclipse -&amp;gt; File -&amp;gt; Spring starter project -&amp;gt; 
(make sure Type: Maven and Packaging:Jar &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb43e6kja6omvmw8zyteh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fb43e6kja6omvmw8zyteh.png" alt="Image description" width="620" height="768"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;then Next;-&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Add dependencies: &lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Template Engine in Thymeleaf
&lt;/li&gt;
&lt;li&gt;Web in Spring web , then finish &lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  what is Template Engine?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A Template Engine is software used to combine Java data (Java objects) with HTML templates to produce formatted output —&amp;gt; generating dynamically rendered web pages&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Java objects → Backend data&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;HTML templates → Frontend design&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Formatted output → Clean HTML response&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Dynamically rendered → Data changes based on user input or back end data.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;#### rendered mean?&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rendering mean  converting  back-end data into a format (HTML/JSON)  then you visually show your the result. &lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  dynamically rendered mean?
&lt;/h4&gt;

&lt;p&gt;Displaying to the changing data(not fixed) on a web page based on the user's action or back end data or back  end update. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;static render = shows same content every time.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;sample.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Welcome to Pizza Shop&amp;lt;/h1&amp;gt;  // Always same text

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;Dynamic render =&amp;gt; Content change based on java data.&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;sample.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1 th:text="${userName}"&amp;gt;&amp;lt;/h1&amp;gt;  // Shows "Welcome, Prasanth" if userName = Prasanth 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;tr th:each="pizza : ${pizzaList}"&amp;gt;
   &amp;lt;td th:text="${pizza.name}"&amp;gt;&amp;lt;/td&amp;gt;
   &amp;lt;td th:text="${pizza.price}"&amp;gt;&amp;lt;/td&amp;gt;
&amp;lt;/tr&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;if your java sends a list of pizzas ,this table will automatically render dynamically based on that list.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;## Why to use Template Engine? &lt;/u&gt;&lt;/p&gt;

&lt;p&gt;1.To render dynamic content in html  using back end data(You get data from your Java code (Controller/Service)&lt;br&gt;
And display that data in your HTML using a template engine).&lt;br&gt;
2.Avoid manually writing long  string(String concatenation(unclean and hard to maintain)) based HTML in java.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;without template engine(manual way)&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;String html = "&amp;lt;p&amp;gt;" + user.getName() + "&amp;lt;/p&amp;gt;";  

// Not readable, difficult to change later ,very Hard to read or not maintainable. 

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3.keep code (java) and view (HTML) separate for easy to maintain&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Template Engines:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Thymeleaf:mostly used to spring boot&lt;/li&gt;
&lt;li&gt;&lt;p&gt;used to create dynamic web page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It works in both web (running inside web server like tomcat)and non-web environments(running background or offline java app like without web server)&lt;br&gt;
.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JSP(JavaServer  Pages):Old template engine, used with Servlet(Java class(Handling requests/responses)like old Controller)  &amp;amp; spring Mvc,not recommeded for new projects&lt;br&gt;
.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JSTL is commonly used with JSP pages for dynamic content rendering,As of now used Thymeleaf.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;FreeMarker:&lt;/u&gt;&lt;br&gt;
supported in spring boot,suitable for emails or pages,java web apps(Frontend+BackEnd+Database).&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Mustache:&lt;/u&gt; usde Java,Spring Boot &amp;amp; javascript.&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;u&gt;Spring web:-&lt;/u&gt;
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;spring Web is a module(tool)  spring framework  ,that  spring web allow to you build web application,REST APIs(@RestController) ,web pages(@controller),Handel Http request(@GetMapping,@PostMapping,@PutMapping,@PatchMapping,@DeleteMapping,@RequestMapping),supports spring MVC architecture. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note:we  will see another blog for only Annotation for what,why,where,when..Coming to  Soon.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;step2:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;After finished create class Products(pojo class)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;step3:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;inside class create private variables
private String name,description,url;
    private int price;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;then, select those variable, Right click mouse -&amp;gt; sourec -&amp;gt; generate getter and setter method. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This Products is pojo class like modal(data) this class filed of  backend Db Columns.controller just request mapper , Pojo class provide the actual data, in this project, actual database is give data. now we see how to get the data from pojo class not to a database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pojo class mean -&amp;gt; Plain old java object that mean Project class  object created in controller class p1 ,p2,p3 this java object ,this object  need  values insitailiation to constructor ,this constructor need to getter(view the value) and setter(set/change the value) in the Pojo class.why we create object in controller class because all the data sent into with help controller class to view the data . &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;step4:&lt;/u&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;We want tor handle web application request mapping and return to  HTML view page.so i will use @Controller&lt;/li&gt;
&lt;li&gt;Create class ProductsController.then   we create the @GetMapping("/products_list") is a Spring annotation used to map HTTP GET requests to specific handler methods within a controller,then create the method like&lt;/li&gt;
&lt;li&gt;public String show_products(),then add 3 objects p1,p2,p3,now came error,so you go generate the constructor for fields same as before done getter and setter for ,source =&amp;gt;generate constructor for fields.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;step:5 &lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; If you want to share multiple objects (like multiple Products) from backed to front end  use List or ArrayList.&lt;/li&gt;
&lt;li&gt;  ArrayList class implement LIst  inteface ,  ArrayList stores elements in index-based order (0, 1, 2...) if want  Later change LINkdedList class instead of Arraylist class that why we use List ,it called like flexbility.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;Products&amp;gt; productList = new ArrayList&amp;lt;Products&amp;gt;();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;if you want change future change anther class for flexibility(like easily to switch) that why use  List.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;List&amp;lt;Products&amp;gt; productList = new LinkedList&amp;lt;&amp;gt;();

        productList.add(p1);
        productList.add(p2);
        productList.add(p3);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;step:6&lt;/u&gt;  we gives Model interface in argument.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public String show_products(Model model)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Model is an interface.It is used to pass all object values like  data (like p1, p2, p3) inside a list(productList) from the controller to the frontend HTML (view) to display.
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    model.addAttribute("productList", productList);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Now the HTML file(products.html) can access productList.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;step:7&lt;/u&gt;&lt;br&gt;
src/mani/resource/template  path create products.html&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04t93bbhs5yy9jsmsb64.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F04t93bbhs5yy9jsmsb64.png" alt="Image description" width="243" height="244"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;add html code.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;step:8&lt;/u&gt; &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Right click your project ,Run as application then paste url &lt;a href="http://localhost:8080/products_list" rel="noopener noreferrer"&gt;http://localhost:8080/products_list&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;scenario:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;pojo/Model (data)=&amp;gt; sends data to Controller =&amp;gt; controller adds data to Model =&amp;gt; returns to View (HTML) =&amp;gt; HTML shows the data.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Pojoclass&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

public class Products {

    private String name,description,url;
    private int price;

    public Products(String name, String description, String url, int price) {
        super();
        this.name = name;
        this.description = description;
        this.url = url;
        this.price = price;
    }
    public String getName() {
        return name;
    }
    public void setName(String name) {
        this.name = name;
    }
    public String getDescription() {
        return description;
    }
    public void setDescription(String description) {
        this.description = description;
    }
    public String getUrl() {
        return url;
    }
    public void setUrl(String url) {
        this.url = url;
    }
    public int getPrice() {
        return price;
    }
    public void setPrice(int price) {
        this.price = price;
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;Example&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Controller
public class ProductsController {

@GetMapping("/products_list")
    public String show_products(Model model)
    {
        Products p1 = new Products ("Apple","phone","https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcS0CHFYxZH8wkjNb98zrWayFHoffcMoZSdxpRfMpc2UB9MPj0seoKo5lZqWiFXYhBFMjMl_kFAzmq5iadxmy30qNBOUDs53Az78RmpzT5Da",145000);
        Products p2 = new Products ("Apple","phone","https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcS0CHFYxZH8wkjNb98zrWayFHoffcMoZSdxpRfMpc2UB9MPj0seoKo5lZqWiFXYhBFMjMl_kFAzmq5iadxmy30qNBOUDs53Az78RmpzT5Da",145000);
        Products p3 = new Products ("Apple","phone","https://encrypted-tbn0.gstatic.com/shopping?q=tbn:ANd9GcS0CHFYxZH8wkjNb98zrWayFHoffcMoZSdxpRfMpc2UB9MPj0seoKo5lZqWiFXYhBFMjMl_kFAzmq5iadxmy30qNBOUDs53Az78RmpzT5Da",145000);
            List&amp;lt;Products&amp;gt; productList = new ArrayList&amp;lt;Products&amp;gt;();
    productList.add(p1);
        productList.add(p2);
        productList.add(p3);
model.addAttribute("productList", productList);
        return "products";
    }

}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;Example:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;products.html&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;!-- ctr+shift+/ --&amp;gt;
&amp;lt;!-- not comlsery  i said thymeleaf template used thats all 
 --&amp;gt;
 &amp;lt;html xmlns:th="http://www.thymeleaf.org/"&amp;gt; 
&amp;lt;head&amp;gt;
    &amp;lt;title&amp;gt;Products List&amp;lt;/title&amp;gt;
&amp;lt;style type="text/css"&amp;gt;
img {
            width: 200px;
            height: auto;
        }
&amp;lt;/style&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
&amp;lt;h1&amp;gt;Product List&amp;lt;/h1&amp;gt;
&amp;lt;!--  for loop to used thymleaf,$ mean to go to contreller class  to get data products list  tp display the division 
img image src is as  source
 --&amp;gt;
 &amp;lt;div th:each ="products : ${productList}"&amp;gt;
 &amp;lt;img th:src="${products.url}"&amp;gt;
  &amp;lt;h2 th:text="${products.name}" &amp;gt;&amp;lt;/h2&amp;gt;
 &amp;lt;h2 th:text="${products.description}" &amp;gt;&amp;lt;/h2&amp;gt;
  &amp;lt;h2 th:text="${products.price}" &amp;gt;&amp;lt;/h2&amp;gt;

&amp;lt;/div&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>springboot</category>
      <category>java</category>
      <category>programming</category>
      <category>productcate</category>
    </item>
    <item>
      <title>Spring Framework (Spring MVC) &amp; Spring Boot (Spring MVC with auto-configuration)</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Thu, 03 Jul 2025 09:47:27 +0000</pubDate>
      <link>https://forem.com/prasanth362k/spring-framework-spring-mvc-spring-boot-spring-mvc-with-auto-configuration-e5h</link>
      <guid>https://forem.com/prasanth362k/spring-framework-spring-mvc-spring-boot-spring-mvc-with-auto-configuration-e5h</guid>
      <description>&lt;h3&gt;
  
  
  Spring Framework (Spring MVC) &amp;amp;  Spring Boot (Spring MVC with auto-configuration)
&lt;/h3&gt;

&lt;p&gt;Spring Boot MVC Full Flow (Two-Way)&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4vs9egaoa2otzgn1xkm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fe4vs9egaoa2otzgn1xkm.png" alt="Image description" width="664" height="521"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;We will see Real-time Example spring  MVc how to flow .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Before going just remember ,  now will see only dynamic page ,we will see up coming blog static page. Now you brain ask what is static and dynamic page.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;u&gt;&lt;strong&gt;Static page&lt;/strong&gt;:&lt;/u&gt; page does not change , same for every  user like index.html.,Does not need controller or DB just enough home.html,contact.html...etc(show directly from /static(Static HTML/CSS/JS goes in src/main/resources/static)or/public folder in spring boot ).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;Dynamic page:&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;user like click "Get Pizza catelog"-&amp;gt; it triggers  GET/pizzas  like flow Controller =&amp;gt; Service =&amp;gt; DB =&amp;gt; returns a dynamic list of pizzas. This list may change(different prices,offers,availability)so its dynamic.
(Dynamic HTML (Thymeleaf, JSP, etc.) uses Controller + Model+view)
**
&lt;u&gt;1.Client sends Request**&lt;/u&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;user click "Get Pizza Catalog" this hits url GET/pizzas,it goes to DispatcherServlet&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;2.DispatcherServlet (Built-in Spring Front Controller)&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;It find the correct controller based url pattern(GET/pizzas)  in Pizza_Controller  because controller class is request handler and responder when hitting something from browser or postman direct came  after DispatcherServlet to controller class, this class request and response  incoming/outgoing.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;3. @RestController or @Controller =&amp;gt; PizzaController&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RestController
public class PizzaController {
    @Autowired
    private PizzaService pizzaService;

    @GetMapping("/pizzas")
    public List&amp;lt;Pizza&amp;gt; getPizzaCatalog() {
        return pizzaService.getAllPizzas();
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Controller handles request and then pass request Service class ,Controller in handle only request/response  and also called Request mapper( it receives Http request from client(browser/postman) maps and the  correct java method using annotation . how it map((http request type)@GetMapping,@PostMapping,@PutMapping,@DeleteMapping) &lt;/li&gt;
&lt;li&gt;It does not contain logic.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Real-time hide request  like POST,PUT,DELETE  from normal user can not give all request like can not see or access it ,every user  hit the request security issue occurred,only accessible that request for admin.we will see depth knowledge spring security( @PreAuthorize("hasRole('ADMIN')")&lt;br&gt;
@PostMapping("/pizzas").&lt;/p&gt;

&lt;p&gt;&lt;u&gt;&lt;br&gt;
In terms of  in real meaning:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;GET for Read, POST for Create, PUT/PATCH for Update, DELETE for Delete.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; now we see only how to flow of mvc architecture not deep dive(POStmapping,DeleteMapping..etc) let understand only flow it give confident make to the project. &lt;/p&gt;

&lt;p&gt;&lt;u&gt; we simply  see what is Responsibilities in @Controller class:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Request Mapping  =&amp;gt; Map URL like /pizzas using @GetMapping(Accepts client/browser/postman requests.),@PostMapping, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Sends input to @Service.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Input Validation =&amp;gt; Use &lt;a class="mentioned-user" href="https://dev.to/valid"&gt;@valid&lt;/a&gt; to validate input models&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Handle Security  =&amp;gt; Restrict access using Spring Security roles(User/Admin)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Return response to the  Data for client      =&amp;gt; JSON for REST, or HTML for Thymeleaf(serialization/Deserialization)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Error Handling   =&amp;gt;Return error status codes to client.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;&lt;u&gt;4. @Service =&amp;gt;  PizzaService&lt;/u&gt;&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Service
public class PizzaService {
    @Autowired
    private PizzaRepository pizzaRepository;

    public List&amp;lt;Pizza&amp;gt; getAllPizzas() {
        return pizzaRepository.findAll(); // JPA built-in method
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This is the business logic layer (Buy 1 get 1 free,total bill calculation,offers,Logging/filterring(type,price..etc), auditing)  all main logic is there in the class , how to function, validation(validate pizza name not empty,check price &amp;gt; 0,discounts,..etc),exception handling(Unexpected event the occurs at runtime which disturb the flow the program is called exception handling, like  if pizza not available custom exception throw PizzaNotFoundException  ), condition(if pizza is veg allow delivery ,if not ,show alert) and other things .&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;we simply  see what is Responsibilities in @Service class:&lt;/u&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Business Logic =&amp;gt; EG:-Buy 1 Get 1 Free” logic, total bill calculation,Logging, auditing etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Validation =&amp;gt; Check if price &amp;gt; 0, name not empty, etc.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Exception Handling =&amp;gt;If pizza not found → throw custom PizzaNotFoundException&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Condition Logic =&amp;gt; If pizza is veg → allow delivery, if not  show alert&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Looping/Filtering =&amp;gt; Filter available pizzas by type, price, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;5.@Repository =&amp;gt; PizzaRepository&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Repository
public interface PizzaRepository extends JpaRepository&amp;lt;Pizza, Integer&amp;gt; {
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Now  we created custom  interface that interface extend another inbuilt interface  JpaRepository. Pizza is the entity/pojo class, Integer is the wrapper for &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt; field, This interface connects to Database Using JpaRepository interface .JpaRepository give   fetch,delete,save,update and other functionality without sql. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It doesn’t need implementation — Spring Data does ,that mean   you do not need to write the logic like how to fetch data,save,delete data (you do not write like this save(),findAll() ,findById(),deleteById()) in the Repository interface - because spring data  Jpa automatically provides it for you.No need to call this function but you can call to service class tho function.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:- &lt;/u&gt;&lt;/p&gt;

&lt;p&gt;you write this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public interface PizzaRepository extends JpaRepository&amp;lt;Pizza, Integer&amp;gt; {
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Above is just an interface , you do not need write below function in this this interface like  findAll(), JpaRepository interface provide or manged .
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
public List&amp;lt;Pizza&amp;gt; findAll() {
    // connect to DB and get pizzas
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;Before i said Do not need to write method or function(spring know belong to the JPA those function)  in the interface,  JpaRepository provide them based on the request, but you can call those method, you can call in the service  class. you must to  call .save(), .findAll(), .deleteById() from the service class to access repository based on request or  logic what your write in the service class.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;//Spring Boot Application Startup Flow with JPA and Repository Initialization&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;application starts after main class inside of run the method (SpringApplication.run(...)), spring  read &lt;/li&gt;
&lt;li&gt; application.properties or application.yml for DB settings (URL, username, password).&lt;/li&gt;
&lt;li&gt;Connects to the database using JPA and Hibernate.&lt;/li&gt;
&lt;li&gt;Creates proxy object for PizzaRepository and registers it as a Spring bean.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt; you can call incomleted JPA Repository method to called in service  in the&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public List&amp;lt;Pizza&amp;gt; getAllPizzas() {
    return pizzaRepository.findAll();
}
//findAll(),deleteById()..etc is a method from which interface?

 //It comes from JpaRepository interface, which your PizzaRepository extends.

// in service class.
public List&amp;lt;Pizza&amp;gt; getAllPizzas() {
    return pizzaRepository.findAll();
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;&lt;strong&gt;Spring Data JPA internally how it is work :&lt;/strong&gt;&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;1.Uses Dynamic proxy it create fake object at runtime for the Repository interface (why? This proxy object handles method calls like save() or findAll() without writing any logic) and 2.uses Reflection like find your method name findAll(), save(), 3.connect them to real SQL behind the scenes, so you do not write method ,you can use it directly, spring writes it for you during runtime.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Note: Proxy object created at run time  by spring only once when the application starts(Note: this proxy object know how to call the correct Sql, Map the object,return results)..it stays in memory (spring container) and it is reused every time request like save() ,delete() comes. it does not disappear each request, singleton bean in the container.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;1.Why use JpaRepository&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Because i am telling spring , i want perform CRUD operations (like save, update, delete, select) on the Pizza table, and the primary key type is Integer.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Pizza =&amp;gt; is your Entity class (mapped to a DB table).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Integer(wrapper class) =&amp;gt; is the type of the &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt; field (like pizzaId).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Why call .save(), .deleteById() in the Service Layer, not Controller?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Because of MVC Architecture:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controller =&amp;gt; Handle HTTP requests (GET, POST, etc.)&lt;/li&gt;
&lt;li&gt;Service =&amp;gt; Business logic (validation, conditions)&lt;/li&gt;
&lt;li&gt; Repository =&amp;gt; Only database access like get the data in database. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;serviceClass&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public void savePizza(Pizza pizza) {
    if(pizza.getPrice() &amp;gt; 0) {          // business logic
        pizzaRepository.save(pizza);    // JPA + Hibernate handles SQL
    } else {
        throw new RuntimeException("Invalid price");
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;we simply  see what is Responsibilities in @Repository  interface:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Save Data  =&amp;gt; save(pizza)&lt;/li&gt;
&lt;li&gt;Fetch Data =&amp;gt;  findAll(), findById(id)&lt;/li&gt;
&lt;li&gt;Custom Queries =&amp;gt;findByName(String name), or @Query annotation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;&lt;strong&gt;6. @Entity (Model(data)) =&amp;gt; Pizza.java&lt;/strong&gt;&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Entity
public class Pizza {
  @Id
  private int id;
  private String name;
  private double price;
//contructor
//getter and setter methods
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;This class create a table in Database( fields=Table_Columns).&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you have  any  doubt  like, we created table ,how to insert,update,modify,delete..etc how , before i said JPA Repositry  gives (or) provide inbuilt method or function(save(), deleteById()..etc ) without Sql query(No need to write SQL manually) based on what you get that request from service class.Hibernate is provide the logic into in-completed    method  underground  operation before i said.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JPARepoistory+Hibernet ,if you need to know please read previous blog.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;we simply  see what is Responsibilities in @Entity (POJO)  class:&lt;br&gt;
Create Table =&amp;gt; @Entity auto-generates DB table&lt;br&gt;
Columns      =&amp;gt; Fields become columns like id, name, price&lt;br&gt;
Validation   =&amp;gt;Add &lt;a class="mentioned-user" href="https://dev.to/notblank"&gt;@notblank&lt;/a&gt;, &lt;a class="mentioned-user" href="https://dev.to/min"&gt;@min&lt;/a&gt;, etc., for field rules&lt;br&gt;
Primary Key  =&amp;gt;Use &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt; and @GeneratedValue&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt; Response Goes Back:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Data comes from DB =&amp;gt; Repository =&amp;gt; Service =&amp;gt; Controller =&amp;gt; DispatcherServlet =&amp;gt; Client&lt;/p&gt;

&lt;p&gt;&lt;u&gt;RestAPI outpt:-&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;
`[
  { "id": 101, "name": "Cheese Pizza", "price": 250 },
  { "id": 102, "name": "Veg Pizza", "price": 300 }
]
``

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>springboot</category>
      <category>springbootmvc</category>
      <category>java</category>
      <category>springmvc</category>
    </item>
    <item>
      <title>spring Boot Introduction -II</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Mon, 30 Jun 2025 13:36:06 +0000</pubDate>
      <link>https://forem.com/prasanth362k/spring-boot-introduction-ii-23l3</link>
      <guid>https://forem.com/prasanth362k/spring-boot-introduction-ii-23l3</guid>
      <description>&lt;p&gt;&lt;strong&gt;Step:1&lt;/strong&gt; Open Eclipse&lt;br&gt;
If you Don not install ,install &lt;br&gt;
&lt;a href="https://www.eclipse.org/downloads/" rel="noopener noreferrer"&gt;https://www.eclipse.org/downloads/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step:2&lt;/strong&gt;  Install Spring Tools (Spring Tool Suite 4) Plugin&lt;br&gt;
1.Go to menu:&lt;br&gt;
Help-&amp;gt; Eclipse marketplace&lt;br&gt;
2.Type Spring tool In search bar&lt;br&gt;
 Spring Tools 4 (aka Spring Tool Suite 4)&lt;br&gt;
then install. Restart Eclipse.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step:3&lt;/strong&gt;  create spring boot project&lt;br&gt;
File-&amp;gt;New-&amp;gt; Spring starter Project.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Demo1 obj1 = new Demo(); // tightly couple
Demo1 obj1; // loosely couple
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now  not need any dependencies , now I skip dependencies.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdrs4kgwx3cgcz6roej5.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ftdrs4kgwx3cgcz6roej5.png" alt="Image description" width="624" height="838"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Jar,War,Dependencies,Pom.xml,Maven,Gradel,Spring,Spring Boot,yml,Application properties,Tomcat..etc to read this Blog:&lt;br&gt;
&lt;a href="https://dev.to/prasanth362k/spring-boot-1-2-class-14h0"&gt;https://dev.to/prasanth362k/spring-boot-1-2-class-14h0&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Group:Package name&lt;br&gt;
Artifact: Project Name&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnemjo12rgr47kjs0a8bc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fnemjo12rgr47kjs0a8bc.png" alt="Image description" width="624" height="838"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Project Structure:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgtcswl5y7ldud3hxrq4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ffgtcswl5y7ldud3hxrq4.png" alt="Image description" width="329" height="302"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Demo1 is project name&lt;/p&gt;
&lt;h4&gt;
  
  
  src/main/java:
&lt;/h4&gt;

&lt;p&gt;This folder contains your java source code:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;@SpringBootApplication main class&lt;/li&gt;
&lt;li&gt;Controllers (@RestController)&lt;/li&gt;
&lt;li&gt;Services (@Service)&lt;/li&gt;
&lt;li&gt;Repositories (@Repository)&lt;/li&gt;
&lt;li&gt;Model classes (@Entity)&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;
  
  
  src/main/resources
&lt;/h4&gt;

&lt;p&gt;This folder stores all configuration and static files like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;application.properties or application.yml&lt;/li&gt;
&lt;li&gt;static/ (HTML, CSS, JS)&lt;/li&gt;
&lt;li&gt;templates/ (Thymeleaf or JSP)&lt;/li&gt;
&lt;li&gt;.sql or .xml files (if needed)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;this location configure Database url,Db username/password,server port number.&lt;/p&gt;
&lt;h4&gt;
  
  
  src/test/java
&lt;/h4&gt;

&lt;p&gt;This used for writing Junit test cases to check if controller/Api is working?,Service logic is correct?, function returns  should give correct output.it helps tester and developer find bugs early.&lt;/p&gt;

&lt;p&gt;In real time  first we done testing the project then deployment.&lt;/p&gt;
&lt;h4&gt;
  
  
  JRE System Library [JavaSE-17]
&lt;/h4&gt;

&lt;p&gt;This Library provide all the core java classes (like String,List,System.out.println) you project needs.without library won't understand basic java code &lt;/p&gt;

&lt;p&gt;For Example-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;System.out.println("Hello World");  // Needs java.lang classes from JRE

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;why it's need?&lt;br&gt;
java compiler version ( project built in using java 17),Runtime version (  you app will run run on java 17), this both need    java 17 or higher version for spring boot .that need to your project. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwt828ie2bv2g0bn88399.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwt828ie2bv2g0bn88399.png" alt="Image description" width="525" height="228"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbonth8u43upd7unarjq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvbonth8u43upd7unarjq.png" alt="Image description" width="469" height="360"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;
  
  
  Maven Dependencies
&lt;/h4&gt;

&lt;p&gt;This file contain .jar file(libraries) downloaded form  maven(internet) based on you what you add dependency from pom.xml .&lt;/p&gt;

&lt;p&gt;why and what Maven dependencies and  JRE System Library [JavaSE-17]  both contain  jar file inside package and inside .class file. &lt;/p&gt;

&lt;p&gt;&lt;u&gt;Maven Dependencies:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6iaqfyv8txl59bg5byn.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fc6iaqfyv8txl59bg5byn.png" alt="Image description" width="800" height="237"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;u&gt;JRE System Library [JavaSE-17]:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rk4m0wwpyu4ve7k4svp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8rk4m0wwpyu4ve7k4svp.png" alt="Image description" width="611" height="239"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;.jar -&amp;gt; is a compressed file format or Zip folder for .class file,.jar contain .class, .properties,xml related. it user for java application not for  web application(war) , can be executable to run with java -var app.jar(main class) , inside .jar you see .compile files. &lt;/p&gt;

&lt;p&gt;.class , created after compiling .java,platform indepenedent(can run any osusing jvm),it is not human readable(byte code(plain text)),it is single file not a zip folder &lt;/p&gt;
&lt;h4&gt;
  
  
  target/
&lt;/h4&gt;

&lt;p&gt;maven stores all compiled code and build files here.After mvn install, .class and .jar files go here.his is auto-generated – don't modify manually.&lt;/p&gt;
&lt;h4&gt;
  
  
  pom.xml
&lt;/h4&gt;

&lt;p&gt;The main configuration file for Maven:&lt;br&gt;
Add dependencies (Spring Web, JPA, Lombok)&lt;/p&gt;

&lt;p&gt;In this blog i demonstrate how to  call  method without  object new keyword only class reference not create object like.Before 2  thing definitely to know one for what is tightly coupling and loose coupling why to use then what is spring container please read my previews blog &lt;/p&gt;

&lt;p&gt;By Default Main program  start this file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

import com.example.demo.service.SMSNotificationService;



@SpringBootApplication
public class DemoApplication {

    private NotificationService notificationService;

    public static void main(String[] args) {
        // before SpringApplication.run(DemoApplication.class, args);
        ConfigurableApplicationContext context  = SpringApplication.run(DemoApplication.class, args);// after 
        //it is tigtely couple relation to avoid like without new key word
        SMSNotificationService sms =context.getBean(SMSNotificationService.class);
        //SMSNotificationService sms ; // = new  SMSNotificationService();
        //SMSNotificationService sms;
        sms.send_message("abcd ","1234");
    }

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step:2 &lt;br&gt;
 I created  SMSNotificationService class&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo.service;


import org.springframework.stereotype.Component;

import com.example.demo.NotificationService;

@Component
public class SMSNotificationService implements NotificationService{

    @Override
    public void send_message(String to ,String message)
    {
        System.out.println("Sending SMS "+to +" : "+message);

    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Step:3  created Interface&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package com.example.demo;

public interface NotificationService {

    //abstract method 
    void send_message(String to ,String message);

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Program Explanation:&lt;/p&gt;

&lt;p&gt;SpringApplication is a Built in spring boot class ,it is helps to create environment for your project . &lt;br&gt;
it does 3 thing:  start your spring boot application , create the  spring container when run  this method SpringApplication.run(DemoApplication.class, args), DemoApplication.class, args why to use you are tell to the spring boot where to begin  otherwise spring boot  do not know where to start you said start from main.then why args , to pass to arguments in command line like: java -jar app.jar --server.port=9090&lt;br&gt;
,args  will contain --server.port=9090, so spring boot can read setting from command line. that all , then i already told SpringApplication.run(DemoApplication.class, args); it give Spring container  just like environment(சூழல்)(to create object inside the environment), we create environment like spring container where will be stored  that place is  ConfigurableApplicationContext (in Built interface)context (reference variable)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;SMSNotificationService sms = context.getBean(SMSNotificationService.class);

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;we Already marked SMSNotificationService @Component annotation ,which tell spring please create object of this class and manages,SpringApplication.run(....) when run this method , start this app and return ConfigurableApplicationContext, this is  the spring Container(environment) that manage the all object(beans) ,we already know that ,already created object , now just   get the bean(object) of class SMSNotificationService.class from  spring container  ,then store the variable sms  , then call method sms.send_message("abcd ","1234");&lt;/p&gt;

&lt;p&gt;context  is a reference to the Spring container,getBean(inbuild function) &lt;/p&gt;

&lt;p&gt;&lt;u&gt;**&lt;br&gt;
 Inversion of control(IoC)  and Spring Container  and Dependency Injection(DI) lets connect with together?**&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;IoC is a design  principle/idea  that says:&lt;/li&gt;
&lt;li&gt;&lt;p&gt;you should not create objects manually using new,instead spring will manage them ,Spring fallow the principle using technique is  called DI.Spring container is the environment the create ,store, and manages all thes beans(objects),these object created and stored  heap memory,DI achived using Constructor Injection ,Field Injection,Setter Injection.To inject dependencies spring use the @Autowired annotation&lt;br&gt;
. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If you Do not mention @componet on top of class , spring can not create and store object in the spring container. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;@Component creates one object inside Spring container (by default singleton). by default singleton mean, by default, Spring creates only one object per class → this is called singleton scope. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;spring by default create only one object per class , can we create multiple? yes &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We learned   2 annotation in this blog:-&lt;/p&gt;

&lt;p&gt;@springBootApplicaion &lt;br&gt;
point your mouse arrow int this annotation the press f3 you will some info.&lt;br&gt;
Inside  you see lot of  annotations combines , in this annotation 3 is important:&lt;/p&gt;

&lt;p&gt;1.@Configuration: spring tells this class provide object(bean) , spring should register them spring container.&lt;a class="mentioned-user" href="https://dev.to/bean"&gt;@bean&lt;/a&gt; tells spring please call method,take return value and store it spring container.(Do  not need to call method manually , automatically call)&lt;/p&gt;

&lt;p&gt;Example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Configuration
public class AppConfig {

    @Bean
    public MyService myService() {
        return new MyService();
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2.@EnableAutoConfiguration&lt;/p&gt;

&lt;p&gt;Tells Spring boot will automatically configure beans  based on what is in the classpath For example , you add spring web in  pom.xml configure Tomcat server , web settings(DispatcherServlet ), set port automatically  you do not do manually ,this automatically configure.&lt;br&gt;
"DispatcherServlet is the front controller in Spring MVC.&lt;br&gt;
It handles all incoming web requests and routes them to the correct @Controller or @RestController  methods."&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;@ComponentScan&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Spring scan the current package and sub package @Component,@Service,@Controller,&lt;br&gt;
@Repository automatically create objects(beans)  and store them  container.Before i said if you mention top of the class @Component object created and store in spring container , @Service,@Controller,&lt;br&gt;
@Repository  internally @Component you can point you mouse cursor in annotation and press f3 .&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Below @annotation class only create objects  and store Spring Container :&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Service
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Controller
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RestController 
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Repository
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;mvt vs mvc&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>dependecyinjection</category>
      <category>inversionofcontrol</category>
      <category>springcontainer</category>
    </item>
    <item>
      <title>spring &amp; Spring Boot Introduction</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sun, 29 Jun 2025 08:32:55 +0000</pubDate>
      <link>https://forem.com/prasanth362k/spring-boot-1-2-class-14h0</link>
      <guid>https://forem.com/prasanth362k/spring-boot-1-2-class-14h0</guid>
      <description>&lt;h2&gt;
  
  
  What is framework?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;A framework is like ready made toolset or structure ,it helps you build application easily , without starting from scratch.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  what is spring?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Spring Framework is a java-based opens-source framework , it is used to build  enterprise level, scalable, maintainable application. &lt;/li&gt;
&lt;li&gt;spring provide infrastructure support for building java  apps by  managing dependencies injection  , configuration, connecting to databases, handle web request and so on.&lt;/li&gt;
&lt;li&gt;Need External Server (Tomcat)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developed by Rod Johnson in 2002.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spring Follows principle Dependency injection(like without new keyword create the object, spring container( create and manage object in heap memory location) ,to use @Autowired) and Aspect-Oriented programming(AOP),MVC(Model-view-Controller)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;AOP: is a programming concept to used to separate common function like logging ,security,transactions from main logic of you application. simple, write common code(logging, security, transactions) and automatically apply you app or application , without rewrite it everywhere&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deployment :  Build WAR, needs external server&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configuration: Manual xml based  configuration it  is older style ,you define everything in xmf flie.spring 2.5 version you can use also  annotation so spring support both XML and annotation , but need more setup. in Spring boot  no need xml Configuration  you just add dependencies in pom.xml,it will auto configure everything ,start the application , scan your classes with annotation like @Restcontroller ,@Service ..etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;spring Example:-&lt;/p&gt;

&lt;p&gt;applicationContext.xml or beans.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;bean id="studentService" class="com.example.StudentService"/&amp;gt;
&amp;lt;context:component-scan base-package="com.example"/&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;spring boot dependency injection Example:-&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;pom.xml 

&amp;lt;dependency&amp;gt;
    &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
    &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;before you added dependency in pom.xml ,now Spring boot code now you can use annotations @ annotation:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@RestController
public class MyController {
    @GetMapping("/hello")
    public String hello() {
        return "Hello!";
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;bean id="myBean" class="com.example.MyBean"/&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Annotation-based:-&lt;br&gt;
you use java annotation instead of xml&lt;br&gt;
Common annotations:&lt;/p&gt;

&lt;p&gt;@Component, @Service, @Repository, @Controller ...etc &lt;/p&gt;
&lt;h2&gt;
  
  
  What is annotation:-
&lt;/h2&gt;

&lt;p&gt;Annotation is meta data that mean data about data, data about data mean provide info about to the spring framework,These annotation used  to  configure,customize, reduce xmL configuration and boilerplate code ( repeated code not a main logic), annotation  make developer develop application or app  simplify development and maintain and efficient ,time reduce..etc. &lt;/p&gt;
&lt;h2&gt;
  
  
  How to avoid boilerplate code:-
&lt;/h2&gt;

&lt;ol&gt;
&lt;li&gt;manual creating beans:-
&lt;/li&gt;
&lt;/ol&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;bean id="studentService" class="com.example.StudentService"/&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;how to avoid : use annotation  like @service and @ auto wired ,automatically crate  and inject bean(object).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Auto Configuration 
Automatically set up Db ,server..etc.it make consuming more time and managnet difficulty so, how to avoid:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;spring boot add automatically configure you application based on dependencies  what you added in the pom.xml and some more setting in application.properties or application.yml. like you want project server tomcat , you can inject dependencies your pom.xml(maven) spring automatically download internet you dependencies.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;In a project you can see src/main/properties under you can see application.properties it used to .&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Configure application setting like port number changing ,Db config..etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;3.Getter/setters&lt;br&gt;
How to avoid Getter/setters : Lombok , remove getter/setters , use &lt;a class="mentioned-user" href="https://dev.to/data"&gt;@data&lt;/a&gt; and @Getter ,.etc.&lt;/p&gt;

&lt;p&gt;application.yml:- &lt;br&gt;
YAML format for settings&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Dependencies and Dependencies injection and types:-
&lt;/h2&gt;

&lt;p&gt;&lt;u&gt;Dependency:-&lt;/u&gt;&lt;br&gt;
Dependency is a class/object that another need to work.&lt;br&gt;
Example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Engine
{
public void start()
{
sytem.out.println("engine started Let to drive");
}
}
class Car {
    Engine engine = new Engine();  // tightly coup
    engine.start();
 // Engine is a dependency
// Engine class change constructor , you must chage  every place that  uses it.  
}

// car depends on Engine , so Engine dependency of car
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;What is Dependency Injection (DI)?&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Dependency Injection is a is a design pattern, do not create the object yourself with new key word(tightly couple) ,spring or spring boot create and inject required object with help of  @Component(you can tell spring ,pleas  create objects of this class,spring will manage and create bean(object) ),spring container(memory location hold all object (@Componet  in top of class use )),@Autowired (connector like  tell spring inject(connect) this object here) ,spring container is one of the part of heap memory. 
Why Heap?
Because:&lt;/li&gt;
&lt;li&gt;    All Java objects are stored in the heap memory&lt;/li&gt;
&lt;li&gt;    Spring beans are also Java objects.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Normal java or  spring boot or spring you can create object with new keyword  it is manual ,it make depend upon other like called tightly coupled when depender class anything change(parent)like constructor like parameter constructor/overload ,you can change all so depending class(child class) constructor or object values.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

class Engine
{
public void start()
{
sytem.out.println("engine started Let to drive");
}
}
class Car {
//Engine engine = new Engine(); // Manual
@Autowired
Engine engine; // Spring injects it

    engine.start();
 // Engine is a dependency
// @Autowired if you want you first  inject dependency  to pom.xml , maven will manage

}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;Why to use DI:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reduce manual object creation&lt;/li&gt;
&lt;li&gt;Loose Coupling - easy to change &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt; Types of Dependency Injection in Spring? &lt;/u&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Constructor Injection
&lt;/h3&gt;

&lt;p&gt;Spring passes dependency to the  constructor&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
class Car {
    private final Engine engine;

    public Car(Engine engine) {
        this.engine = engine;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  2️2.Setter Injection:-
&lt;/h3&gt;

&lt;p&gt;Spring sets dependency using setter method&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
class Car {
    private Engine engine;

    @Autowired
    public void setEngine(Engine engine) {
        this.engine = engine;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  3. Field Injection
&lt;/h3&gt;

&lt;p&gt;Spring injects directly into the field&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@Component
class Car {
    @Autowired
    private Engine engine;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;Aop example:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;without AOP( repeating code every where)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;public class BankService {

    public void withdraw() {
        System.out.println("Checking permission...");
        System.out.println("Logging: withdraw started");
        System.out.println("Withdrawing money...");
        System.out.println("Logging: withdraw completed");
    }

    public void deposit() {
        System.out.println("Checking permission...");
        System.out.println("Logging: deposit started");
        System.out.println("Depositing money...");
        System.out.println("Logging: deposit completed");


    }

    public void checkBalance() {
        System.out.println("Checking permission...");
        System.out.println("Logging: check balance started");
        System.out.println("Showing balance...");
        System.out.println("Logging: check balance completed");
    }
}

// main logic with extra logic , hard to mange,messy..etc

With AOP (clean and separate)

public class BankService {

    public void withdraw() {
        System.out.println("Withdrawing money...");
    }

    public void deposit() {
        System.out.println("Depositing money...");
    }

    public void checkBalance() {
        System.out.println("Showing balance...");
    }
}
Step 2: Write AOP for Logging and Permission
@Aspect
@Component
public class LoggingAspect {

    // Log before any method in BankService
    @Before("execution(* com.example.BankService.*(..))")
    public void logBefore(JoinPoint jp) {
        System.out.println("Logging: " + jp.getSignature().getName() + " started");
    }

    @After("execution(* com.example.BankService.*(..))")
    public void logAfter(JoinPoint jp) {
        System.out.println("Logging: " + jp.getSignature().getName() + " completed");
    }

    @Before("execution(* com.example.BankService.*(..))")
    public void checkPermission() {
        System.out.println("Checking permission...");
    }
}
// But you didn’t write this logging or permission code inside the withdraw() method — Spring AOP handled it for you.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Is Spring only for Java?
&lt;/h2&gt;

&lt;p&gt;yes, Spring is only for Java and JVM-based languages (like Kotlin, Groovy).&lt;br&gt;
It is not for Python, C++, etc.&lt;/p&gt;
&lt;h2&gt;
  
  
  Why use Spring?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;To build robust(Strong,stable,handle errors well,)loosely coupled(classes are independent not tightly coupled , Java applications.
Can integrate with JPA/Hibernate, JDBC, Security, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;JPA (Java Persistence API)&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JPA is just a specification (like a set of rules).&lt;/li&gt;
&lt;li&gt;It defines how Java objects should be saved into a database (ORM – Object Relational Mapping).&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JPA(rules/interface) doesn’t do anything by itself – it needs a real tool to work.Needs  implementation like Hibernate.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JPA annotations like @Entity, &lt;a class="mentioned-user" href="https://dev.to/id"&gt;@id&lt;/a&gt; ..etc&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Provided by Java (javax.persistence)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spring Data JPA is a module that provides the JpaRepository interface to access and manage data without writing boilerplate SQL code(not need with query again and again).&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Hibernate&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    Hibernate is a real tool (framework) that follows JPA rules. &lt;/li&gt;
&lt;li&gt;Hibernate Is an implementation of JPA.&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;It does the actual work of connecting your Java classes to the database.
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;JPA not provide actual code,it says you need a save()...etc,Hibernate the gives actual code for save()...etc.(Note:JpaRepository is an interface (from Spring Data JPA) — it has methods like .save(), .delete()..etc that are not implemented method(method signature — no body, no SQL, no logic ).Hibernate is the ORM tool that is implements JpaRepository inteface and Hibernate  provide the logic those non implemented method  behind scene like  SQL queries (INSERT, UPDATE, DELETE, etc.),Hibernate also does (ORM) Object Relational Mapping that mean  java object  mapped to table row, java fields mapped to columns to database tables and vice versa.,it save the data in the correct column and row.)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Spring boot use Hibernate internally to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create tables.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It creates or writes the SQL: INSERT INTO pizza (...) VALUES (...)like insert/update/delete/save data  query writing for behind the scene. &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It connects to the database - It saves the data&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CRUD Uperation(insert/update/save/delete).&lt;br&gt;
convert Java objects from to SQL data &lt;/p&gt;

&lt;p&gt;pom.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;spring-boot-starter-data-jpa&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
// It automatically includes( behind the scenes)  Hibernate as the default JPA provider.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:-&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Think of:-&lt;/u&gt;&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JPA = Rulebook
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Hibernate = Worker who follows the rulebook&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;sql maually, JDBC, Security, etc.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Lets combine with JpaRepository+Hibernate
&lt;/h3&gt;

&lt;p&gt;JPA is the rule book, like a manager.&lt;br&gt;
Hibernate is the worker, who does the real job under the hood (underground).&lt;/p&gt;
&lt;h4&gt;
  
  
  What Happens in Real Time?
&lt;/h4&gt;

&lt;p&gt;When you call .save(), .delete(), .findAll() from JpaRepository:JPA defines these methods.        Hibernate writes the SQL and executes it in the background (under the hood).&lt;/p&gt;
&lt;h2&gt;
  
  
  What is JDBC?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;JDBC = Java Database Connectivity (manual SQL writing and executing)
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;u&gt;When to use:&lt;/u&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;When you want manual control over SQL.
&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;How Spring Integrates:&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spring provides Jdbc Template to reduce boilerplate code.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Spring Security:-&lt;/u&gt;&lt;br&gt;
What is it?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;    A module in Spring for:&lt;/li&gt;
&lt;li&gt;        Login/Logout&lt;/li&gt;
&lt;li&gt;        User Roles (admin, user, etc.)&lt;/li&gt;
&lt;li&gt;        Password Encryption&lt;/li&gt;
&lt;li&gt;        Authorization (what a user can access)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;How Spring Integrates:&lt;/u&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Add spring-boot-starter-security&lt;/li&gt;
&lt;li&gt;    Configure user roles, login form, URL access rules
&lt;u&gt;Example &lt;/u&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Tightly coupling:-&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
    Engine engine = new Engine(); // direct object
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;loose coupling&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Car {
    @Autowired
    Engine engine; // Spring will inject it
// you can change the engine ,test the calss , or reuse iit 
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;IT save time ,Make code clean and reusable&lt;/li&gt;
&lt;li&gt;It give tools for web apps ,security ,database,JPA/Hibernate, JDBC.&lt;/li&gt;
&lt;li&gt;Supports DI, AOP, and MVC, simplifying development.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  what is Spring Boot?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Spring boot is a simplified version of the Spring Framework. It helps to create spring applications quickly and with less configuration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Spring Boot = spring + Ready made setup(like auto configuration ..etc) +Less code + fast to development like you can create java web apps to fast.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developed by Pivotal (now VMware) in 2014.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Deployment : Build JAR with embedded Tomcat/Jetty(server)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Use Case:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;spring : Full control,  more configuration setup ,suitable for  custom projects&lt;br&gt;
Spring Boot: Fast   startup the projects,Rest APIS, Micro-service, ..etc.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example: &lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;without spring: you write 100 lines for setup code.&lt;/li&gt;
&lt;li&gt;with spring : you write 20 lines.&lt;/li&gt;
&lt;li&gt;With spring Boot : you write 10 lines&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  why to use Spring Boot?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Reduce boilerplate code( boilerplate code- repeated code , you write agin and again) ,to avoid writing unnecessary code.&lt;/li&gt;
&lt;li&gt;Easy to start project with pre-configured setups.it useful for beginners.&lt;/li&gt;
&lt;li&gt;To avoid complex XML configurations.&lt;/li&gt;
&lt;li&gt;Ideal for micro services architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*&lt;em&gt;we will learn some concept or tool or other terminology  used in the  spring boot project *&lt;/em&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  What is Maven?
&lt;/h2&gt;

&lt;p&gt;(A Java tool to manage dependencies and build project)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Maven is a build and dependency management tool for Java projects.&lt;/li&gt;
&lt;li&gt;Configuration format : XML (pom.xml)&lt;/li&gt;
&lt;li&gt;Speed: Slower&lt;/li&gt;
&lt;li&gt;Used in Spring Boot, standard Java app
s&lt;/li&gt;
&lt;li&gt;Dependency Management: Downloads libraries (JAR files) only from Maven Central repository&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;- It helps:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Download and manage external libraries (like Spring Boot..etc)&lt;/li&gt;
&lt;li&gt;  Build your project (compile, test, package into .jar or .war)&lt;/li&gt;
&lt;li&gt; Run your project with the required libraries&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What is Gradle?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Gradle Build &amp;amp; Dependency Management Tool like maven.&lt;/li&gt;
&lt;li&gt;Configuration format : Groovy or Kotlin DSL (build.gradle)&lt;/li&gt;
&lt;li&gt;synax: Concise like script based &lt;/li&gt;
&lt;li&gt;speed: Faster&lt;/li&gt;
&lt;li&gt;Dependency Management: Can download from Maven Central, JCenter, or custom/private sources.&lt;/li&gt;
&lt;li&gt;used in :  Andriod apps, spring Boot Apps ,large java projects.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What is jar ?
&lt;/h2&gt;

&lt;p&gt;jar = Java ARchive&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Jar File is a packaged java application(all java .class files are combined into one file .jar so it easy to run ,share,or deploy ) used to run standalone programs.JAR file is a zip file that contains your Java program&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;standalone mean:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;work independently.&lt;/li&gt;
&lt;li&gt;no need to deploy on separate server tomcat manually.that mean just run the jar file directly using java no need to put in separate server like tomcat. &lt;/li&gt;
&lt;li&gt;Easy to run,test and move.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:&lt;/u&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;you build you spring boot app  like myapp.jar&lt;/li&gt;
&lt;li&gt;run  using java -jar myapp.jar
3.spring boot start its own server on port of 8080 by default
4.you open  browser -&amp;gt;&lt;a href="http://localhost:8080" rel="noopener noreferrer"&gt;http://localhost:8080&lt;/a&gt;
app is running this is called deployment for JAR&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Jar file contains all  compiled  .class files, libraries, and metadata(info about how to run).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Runs directly using: java -jar app.jar&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;used  in Spring Boot, microservices, and CLI apps.Running desktop or back end apps.Standalone Java applications&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;jar not need install server separately , include tomcat server run app directly &lt;br&gt;
Tools   -&amp;gt; Maven/Gradle to build .jar&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  what is WAR?
&lt;/h2&gt;

&lt;p&gt;WAR = Web Application Archive&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;A WAR file is a packaged Java web application(means java web project with contain HtmL,CSS,Java code,etc)  that zipped into one .war file to be run on a webserver) used to deploy on web servers like Tomcat in deploy. Deploy  mean putting your application on  a sever so  users can access it.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;WAR Contains: .class files + HTML, CSS, JS, JSP, WEB-INF folder, etc.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:- &lt;/u&gt;&lt;/p&gt;

&lt;p&gt;1.you build you app -&amp;gt; myapp.war ( create you web app)&lt;br&gt;&lt;br&gt;
2.you copy to  C:\tomcat\webapps\myapp.war (after placed your web app in the server tomcat) &lt;br&gt;
3.Start tomcat&lt;br&gt;
4.open browser and paste =&amp;gt;  &lt;a href="http://localhost:8080/myapp" rel="noopener noreferrer"&gt;http://localhost:8080/myapp&lt;/a&gt; (server run your app and it make  available in the browser) &lt;br&gt;
now deployed and running &lt;/p&gt;

&lt;p&gt;Deploy  -&amp;gt; Putting your app on a server to run &lt;br&gt;
WAR file -&amp;gt;  The package you give to the server&lt;br&gt;
Tomcat  -&amp;gt; The server that runs your web app.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;used for Deploying java apps to web server(Apache Tomcat) .Web-based applications (Servlet, JSP, deployed to server)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Tools    -&amp;gt; Maven/Gradle to build .war&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What is pom.xml in Spring Boot ?
&lt;/h2&gt;

&lt;p&gt;(XML file used by Maven to define project setup)&lt;br&gt;
POM = Project Object Model&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pom.xml it is a XML file(your required dependency placed or add  into pom.xml) used by maven tool ,that to tool manage the dependencies  in you project. pom.xml tells maven what is project name(artifactId),package name (groupId),what version,What dependencies (JARs) to download,What plugins or settings to use.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  What is XML in pom.xml?
&lt;/h2&gt;

&lt;p&gt;XML = Extensible Markup Language&lt;/p&gt;

&lt;p&gt;It is used to store structured data.&lt;br&gt;
it use tags likevalue&lt;br&gt;
XML is platform-independent and readable by humans and machines. that mean do not depend on any operating system ,can be used or support on every platform like  Windows, linux,mac,android,server...etc&lt;/p&gt;
&lt;h2&gt;
  
  
  What is a Dependency in pom.xml?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;I want to use some external java library or tool like spring boot ,jpa,hibernate, please download and include my project. like simply say  maven is a tool  it  mange dependencies in the project,that dependencies  placed  in pom.xml  for example you add dependencies in  pom.xml spring tell    maven tool download dependencies form internet  file  like jar file , that jar file combination package and class available.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:-&lt;/p&gt;

&lt;p&gt;pom.xml&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;dependency&amp;gt;
  &amp;lt;groupId&amp;gt;org.springframework.boot&amp;lt;/groupId&amp;gt;
  &amp;lt;artifactId&amp;gt;spring-boot-starter-web&amp;lt;/artifactId&amp;gt;
&amp;lt;/dependency&amp;gt;
// this dependency say  i want to use spring boot for build web application, maven download required library the you add project  @RestController, @GetMapping, etc.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What Happens When You Use Maven?
&lt;/h2&gt;

&lt;p&gt;When you run:&lt;br&gt;
mvn clean install&lt;/p&gt;

&lt;p&gt;Maven will:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Read pom.xml&lt;/li&gt;
&lt;li&gt;Download all dependencies (JAR files) from the internet (Maven Central)&lt;/li&gt;
&lt;li&gt;Compile the code&lt;/li&gt;
&lt;li&gt;Run tests&lt;/li&gt;
&lt;li&gt;Create a .jar or .war file to run your app&lt;/li&gt;
&lt;/ol&gt;
&lt;h2&gt;
  
  
  Where Are the JAR Files Stored?
&lt;/h2&gt;

&lt;p&gt;Maven downloads all .jar files into:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;C:\Users\YourName\.m2\repository   (Windows)
or
~/.m2/repository                   (Linux/macOS)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;JAR in Maven Downloaded from the internet and stored in .m2&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;java is WORA feature write once anywhere ,platform independence , windows, linux. &lt;br&gt;
500  .class to  files to :Zip : in java caller jar &lt;/p&gt;

&lt;p&gt;&lt;u&gt;.yaml/.yml&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;YAML Ain’t Markup Language:Easy to read and write.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Used in  : Configuration files (application.yml)in Spring Boot, Docker (docker-compose.yml),  Kubernetes (deployment.yml), Ansible, etc.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Feature : Human-readable data serialization language , indentation-based.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Structure: Based on indentation (like Python)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports: Key-value pairs, lists, nested structures.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;No tags, no brackets&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-time use: Configure properties like ports, DB, paths.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;data serialization language mean: &lt;br&gt;
IT means it help store data in  structured ,readable format.&lt;br&gt;
IT can represent data like string,number,list,object..etc.&lt;br&gt;
That data can be converted  programming  object/variable into a file  format like YAML,JSON,XML,binary file so it can be stored or send.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Example:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Your Java Serialization Code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import com.fasterxml.jackson.dataformat.yaml.YAMLMapper;
import java.io.File;

public class SimpleSerialize {
    public static void main(String[] args) throws Exception {
        User user = new User();
        user.name = "Prasanth";
        user.age = 24;

        YAMLMapper mapper = new YAMLMapper();
        mapper.writeValue(new File("user.yml"), user); // Serialization
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output in user.yml (YAML format):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;name: "Prasanth"
age: 25

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;reverse code YAML yo JAVA object = deserilation  &lt;/p&gt;

&lt;h2&gt;
  
  
  What is Deserialization?
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Mean stored convert data format like YAML or JSON or XML(human readable format)   back into java/python object or variable. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example of YAML configuration:&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;server:
  port: 8080
spring:
  application:
    name: MySpringBootApp
  datasource:
    url: jdbc:mysql://localhost:3306/mydb
    username: user
    password: password
logging:
  level:
    org.springframework: INFO
    com.example.myapp: DEBUG
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;YAML is a language  to store and share data in a clean and readable format,used for configuration.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;JSON&lt;/u&gt;&lt;br&gt;
JSON-JavaScript Object Notation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A lightweight, human-readable data format&lt;/li&gt;
&lt;li&gt;Commonly used for data exchange between client &amp;amp; server. for example spring Boot can automatically convert java object to Json responsce)(Serialization) and JSON to Java  object(post)request input (Deserialization) using a library called Jackson by default.&lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;Spring Boot uses Jackson&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Spring Boot has built-in support for JSON vice versa  the Jackson library.&lt;/li&gt;
&lt;li&gt;    Converts (serializes) Java objects → JSON&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Converts (deserializes) JSON → Java objects
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Happens automatically using annotations like @RequestBody and @ResponseBody (or @RestController)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Key Annotations&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Annotation   Purpose&lt;br&gt;
@RequestBody     JSON → Java object (deserialization)&lt;br&gt;
@ResponseBody    Java object → JSON (serialization)&lt;br&gt;
@RestController  Combines @Controller + @ResponseBody&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Jackson default Json Processor it is auto configured.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Q1. How does Spring Boot handle JSON?&lt;br&gt;&lt;br&gt;
Using Jackson library (automatically)&lt;br&gt;
Q2. How do you send/receive JSON in REST API?   @RequestBody, @ResponseBody, or @RestController&lt;br&gt;
Q3. How do you customize JSON fields?   Use @JsonProperty, @JsonIgnore, etc.&lt;br&gt;
Q4. What if the JSON format is wrong?&lt;br&gt;&lt;br&gt;
Spring throws HttpMessageNotReadableException&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Important Points&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;   Jackson is auto-configured in Spring Boot → no setup needed.&lt;/li&gt;
&lt;li&gt;    JSON input should match Java class field names (case-sensitive).&lt;/li&gt;
&lt;li&gt;    Use validation annotations like @NotNull, @Size with &lt;a class="mentioned-user" href="https://dev.to/valid"&gt;@valid&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You can control JSON output with @JsonInclude, @JsonIgnore, etc.
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-time use    REST APIs, mobile/web apps &lt;br&gt;
(frontend-backend data exchange)    &lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Tomcat:-&lt;br&gt;
Tomcat is server that run you java web application(WAR) also embedded(include) inside spring Boot Jar apps not java application((JAR)not need install server manually).&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Spring helps developer connect their web application to number data base.&lt;/li&gt;
&lt;li&gt;It support  relational databases and non relational database &lt;/li&gt;
&lt;/ul&gt;

&lt;ol&gt;
&lt;li&gt;What is a Relational Database (RDBMS)?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;RDBS is a Structured data - it mean Data&lt;br&gt;
mean:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data is Stored  fixed format in tables(Column and rows)  like Excel sheet.Every row must follow the same pattern. like Columns define the pattern(schema) so row must follow  it and fill same columns with valid data. or you can not skip columns unless NULL is allowed  or it has  default value.Note you can not suddenly add 4  the value in the table ,that why structured .&lt;/li&gt;
&lt;li&gt;Uses Sql (structure Query language) to query and manage data
Example:-
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;CREATE TABLE student (
  id INT,
  name VARCHAR(50),
  age INT DEFAULT 18
);

INSERT INTO student (id, name) VALUES (1, 'Prasanth');

if you try this ,it will fail
INSERT INTO students (id, name) VALUES (2, 'Rahul');

// because RDBMS is Structured data must fallow this rules(column(schema(rule)))the rows.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptslewlzxmbp846t7txq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fptslewlzxmbp846t7txq.png" alt="Image description" width="300" height="74"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;above the table:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;   Every row must have 3 values: id, name, and age&lt;/li&gt;
&lt;li&gt;    You can’t suddenly add a 4th value in one row&lt;/li&gt;
&lt;li&gt;    You can’t skip columns unless NULL is allowed. This is called structured data.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Examples of RDBMS:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;   MySQL&lt;/li&gt;
&lt;li&gt;    PostgreSQL&lt;/li&gt;
&lt;li&gt;    Oracle&lt;/li&gt;
&lt;li&gt;    SQL Server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Real-World Use:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;  Banking systems&lt;/li&gt;
&lt;li&gt;    Employee or customer records&lt;/li&gt;
&lt;li&gt;    E-commerce product databases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;What is a Non-Relational Database (NoSQL)?&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Stores data in a flexible format — not in rows and columns.&lt;br&gt;
No fixed schema — you don’t need to define table structure first.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Good for handling unstructured or changing data&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Stores data as:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; JSON-like documents (MongoDB)&lt;/li&gt;
&lt;li&gt; Key-value pairs (Redis)&lt;/li&gt;
&lt;li&gt; Graphs (Neo4j)&lt;/li&gt;
&lt;li&gt;  Wide-columns (Cassandra)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Currently using Tools and version:-&lt;br&gt;
Eclipse IDE - 2025-06 &lt;br&gt;
Java  - Java 21 (LTS)&lt;br&gt;
Springboot -3.5.3&lt;br&gt;
Firefox -v140.0.2 &lt;br&gt;
Ubuntu -Ubuntu 22.04 LTS&lt;br&gt;
Tomcat  10.1.42&lt;br&gt;
Database -PostgreSQL 15+&lt;/p&gt;

&lt;h3&gt;
  
  
  How to add Third party  jar add in you project ?
&lt;/h3&gt;

&lt;p&gt;your project right click ,choose  bulid path configure build path  libraries class-path add-external Jar &lt;/p&gt;

&lt;p&gt;How to inject dependency in pom.xml different way ?&lt;br&gt;
&lt;a href="https://mvnrepository.com/" rel="noopener noreferrer"&gt;https://mvnrepository.com/&lt;/a&gt; you can search your required dependencies(version)  paste you in pom.xml.&lt;br&gt;
(Or)&lt;br&gt;
install  spring tool for Eclipse &lt;a href="https://spring.io/tools(" rel="noopener noreferrer"&gt;https://spring.io/tools(&lt;/a&gt; we will see later how to install and use)&lt;br&gt;
(Or)&lt;br&gt;
In Eclipse -&amp;gt;Help-&amp;gt; market place -&amp;gt; search spring latest version.&lt;/p&gt;

&lt;p&gt;apachi poi =&amp;gt; &lt;a href="https://poi.apache.org/" rel="noopener noreferrer"&gt;https://poi.apache.org/&lt;/a&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Apachi poi is a Java library used to read, write, and modify data microsft office files and generate reports ,Automatic document like:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Excel (XLS/XLSX)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Word (DOC/DOCX)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;PowerPoint (PPT/PPTX)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;if you want your project you can add this dependencies  based on project purpose or need.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Spring boot other some important point:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;Spring boot &lt;br&gt;
opinionated view of the Spring platform and third-party  libraries so you can get started with minum fuses:- That mean&lt;/p&gt;

&lt;p&gt;Spring Boot is opinionated framework , spring boot give default  setup  like (server(Tomcat),db,JSON..etc) setting,libraries,configurations..etc you can start with basic setup,so you don’t have to decide everything yourself create application faster with less configuration, best for beginners ,if you want decide everything yourself go to spring.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Features&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create stand-alone Spring applications&lt;/li&gt;
&lt;li&gt;    Embed Tomcat, Jetty or Undertow directly (no need to deploy WAR files)&lt;/li&gt;
&lt;li&gt;    Provide opinionated 'starter' dependencies to simplify your build configuration&lt;/li&gt;
&lt;li&gt;    Automatically configure Spring and 3rd party libraries whenever possible&lt;/li&gt;
&lt;li&gt;    Provide production-ready features such as metrics, health checks, and externalized configuration&lt;/li&gt;
&lt;li&gt;    Absolutely no code generation and no requirement for XML configuration&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf24g6l81i0o7trohg9o.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fbf24g6l81i0o7trohg9o.png" alt="Image description" width="514" height="166"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Finally we came conclusion part of this   spring boot blog we will upcoming blog &lt;br&gt;
spring boot projects to Travel...&lt;/p&gt;

&lt;p&gt;W&lt;/p&gt;

</description>
      <category>programming</category>
      <category>java</category>
      <category>spring</category>
      <category>springboot</category>
    </item>
    <item>
      <title>How to change spring boot banner and set to the spring profile</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Fri, 20 Jun 2025 09:54:20 +0000</pubDate>
      <link>https://forem.com/prasanth362k/how-to-change-spring-boot-banner-and-set-to-the-spring-profile-ig</link>
      <guid>https://forem.com/prasanth362k/how-to-change-spring-boot-banner-and-set-to-the-spring-profile-ig</guid>
      <description>&lt;h2&gt;
  
  
  How to change spring boot banner in Eclipse IDE?
&lt;/h2&gt;

&lt;p&gt;Step 1: Open your spring Boot Project in Eclipse&lt;br&gt;
Step 2:  Open src/main/resources Folder in eclipse&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In the project Explorer (left side)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;expand:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5a34djeb1c4oz3sncon.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl5a34djeb1c4oz3sncon.png" alt="Image description" width="287" height="164"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;step 3: Right click resource folder -&amp;gt; New -&amp;gt; file -&amp;gt; Give name LOWER Case Letter only.&lt;/p&gt;

&lt;p&gt;Example: banner.txt&lt;br&gt;
then click Finish.&lt;/p&gt;

&lt;p&gt;like&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;src/main/resources/banner.txt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;step 4: Add custom banner content&lt;/p&gt;

&lt;p&gt;open your created file  paste your custom test or  ASCLL art.&lt;/p&gt;

&lt;p&gt;Example:-&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2looo2ckm0lzc6ogjq63.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2looo2ckm0lzc6ogjq63.png" alt="Image description" width="800" height="657"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;IF you want your own ASCLL text:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://patorjk.com/software/taag" rel="noopener noreferrer"&gt;https://patorjk.com/software/taag&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Step 5: Right click main class(@SpringBootApplication)  &lt;/p&gt;

&lt;p&gt;Runs As -&amp;gt; Java Application&lt;/p&gt;

&lt;h3&gt;
  
  
  IF you Do not Want  Banner:-
&lt;/h3&gt;

&lt;p&gt;Step 1: Open  application.properties in your project.&lt;/p&gt;

&lt;p&gt;Location  src/main/resource in Double click application.properties add below line.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;spring.main.banner-mode=off

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  What is a Spring Profile?
&lt;/h2&gt;

&lt;p&gt;In Spring Boot , a profile is a to  define different configuration for different  environment&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;dev (development)&lt;br&gt;
test (testing)&lt;br&gt;
prod (production)&lt;/p&gt;

&lt;p&gt;Above mention each profile separate beans(objects)  or you configuration setting tells that where you app is running.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why use Profile?
&lt;/h3&gt;

&lt;p&gt;just think like:&lt;/p&gt;

&lt;p&gt;in development ,you want to connect to local database.&lt;br&gt;
int production , you want to connect to live database.&lt;/p&gt;

&lt;p&gt;Spring Profile help you switch easily between configuration  without  changing main code.&lt;/p&gt;

&lt;h3&gt;
  
  
  How to  Set a spring Profile:-
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. create separate Property Files:-
&lt;/h4&gt;

&lt;p&gt;go to:&lt;/p&gt;

&lt;p&gt;src/main/resources/&lt;/p&gt;

&lt;p&gt;Right click resources folder -&amp;gt; new -&amp;gt; file&lt;/p&gt;

&lt;p&gt;&lt;u&gt;create files like:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;application-dev.properties&lt;/p&gt;

&lt;p&gt;application-prod.properties&lt;/p&gt;

&lt;p&gt;inside file  type your configuration details &lt;/p&gt;

&lt;h4&gt;
  
  
  2. In application.properties
&lt;/h4&gt;

&lt;p&gt;=&amp;gt; application.properties&lt;/p&gt;

&lt;p&gt;spring.profiles.active=dev&lt;/p&gt;

&lt;h4&gt;
  
  
  3.Run the Application :
&lt;/h4&gt;

&lt;p&gt;Right-click main class → Run As → Java Application&lt;/p&gt;

</description>
      <category>programming</category>
      <category>springboot</category>
      <category>java</category>
      <category>springbanner</category>
    </item>
    <item>
      <title>Interface</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Tue, 17 Jun 2025 14:52:31 +0000</pubDate>
      <link>https://forem.com/prasanth362k/interface-54an</link>
      <guid>https://forem.com/prasanth362k/interface-54an</guid>
      <description>&lt;p&gt;What is an Interface in Java?&lt;/p&gt;

&lt;p&gt;Interface in java called blueprint of a class or reference type ,that contains only abstract methods(method without body)(until java 7) and can also contain default/static methods(from java 8)&lt;/p&gt;

&lt;p&gt;why interface say reference type in java?&lt;/p&gt;

&lt;p&gt;In java reference type means variable  does not hold the actual value  it is pointing to the object memory. so you can not create object in interface ,but you can use it  a reference of the object of a class when implements . like you using class and  array&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Vehicle honda = new Car();

Vehicle = interface (or superclass) -&amp;gt; reference type
honda =  variable ( reference variable) -&amp;gt; to point s the object
new car() = object/instace -&amp;gt; Actual object in memory  

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;why interface called blueprint of a class?&lt;/p&gt;

&lt;p&gt;Interface defines what a class should do, not how.&lt;br&gt;
That mean (do)  you must have fallow the method name and signature(override) from the interface. (not how) interface does not say  what code or logic to write inside that implement method, so interface rule is what should be done  but not how ti should be done.&lt;/p&gt;

&lt;p&gt;Example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Vehicle // when implement any class you should override the abstract method but not how.
{
void start(); 
}

class Car implements Vehicle
{
public void start()
{
System.out.println("Car start with key");
}
}  

class Bike implements Vehicle
{
public void start()
{
System.out.println("Bike start with key and kick..etc ");
}
}

public class ShowRoom
{
    public static void main(String[] args) {
Vehicle car1 = new Car(); //interface reference pointing to Car object.
}

}

// must to implement the method
// but not how like whether key or key and kick 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Spring Boot real-world interface used with @Autowired (Loose coupling- does not depend directly ) we will see later.  &lt;/p&gt;

&lt;p&gt;Why Interface is Called a Contract?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;You must implement all abstract methods from the interface, otherwise your class will not compile.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interface contain static  constants and abstract method. static constants mean all variables in interface by default  public static final ,even if you do not write them, it mean fixed value , shared and accessible without object.&lt;br&gt;
&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Contract {
    int VALUE = 100; // same as: public static final int VALUE = 100;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Why use Interfaces?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;To achieve 100% abstraction (before java 8)&lt;/li&gt;
&lt;li&gt;To support multiple inheritance(java does not support multiple inheritance) 
Loose coupling between classes
used for dependency  injection.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Where is Interface used?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;In real-time projects :- for layers like service ,repository ... etc.&lt;/li&gt;
&lt;li&gt;In frameworks like Spring, hibernate(e.g JpaRepository, ApplicationContext ..etc&lt;/li&gt;
&lt;li&gt;In callbacks/event handling (Gui, Threads)&lt;/li&gt;
&lt;li&gt;In API design: to define method contracts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How does Interface work?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A class implements an interface using implements keyword.&lt;/li&gt;
&lt;li&gt;The class must to implement(override all methods)  for all abstract methods in the interface.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Which types of Interfaces are in Java?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Normal Interface - with abstract,default,static methods.&lt;/li&gt;
&lt;li&gt;Functional Interface -only one abstract method(e.g, Runnable ,Comparable).&lt;/li&gt;
&lt;li&gt;marker Interface - no methods ,only used to mark like tags (e.g, serializable ,Cloneable)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(we will see interface types upcoming blogs)&lt;/p&gt;

&lt;p&gt;Why Interface provides 100% Abstraction (before Java 8) &lt;br&gt;
Interface Rules:-&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Methods -&amp;gt; By default ,abstract and public&lt;/li&gt;
&lt;li&gt;variable -&amp;gt; By default , public , static and final.&lt;/li&gt;
&lt;li&gt;Can not  use   constructor , instance variable, can not create object &lt;/li&gt;
&lt;li&gt;class extend one class but class can implements multiple interface(multilevel inheritance)&lt;/li&gt;
&lt;li&gt;interface extend another interface&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In interface implicitly abstract(incomplete method only-No body), you  do not need to use abstract keyword when declaring in the interface.&lt;br&gt;
Let see detail information.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. Abstract method:-

interface Human{
void  eat(); //implicitely public and abstract,you do not nee to mention public abstract.
public abstract void eat(); // same as above

2.Default methods( introduced in java 8)

interface Human{
//  you must to explicit declare the default
// not abstract method
default void  eat()
{
System.out.println("humans are eat veg and non-veg");
} 
//do not define
default void eat(); // not valid 


}

3.static methods(from java 8)
// explicitly declared static
// not abstract.
interface Human{
static void  eat()
{
System.out.println("humans are eat veg and non-veg");
}

4.Private method(java 9+)
// must to declare private
//not abstract method
interface Human{
private void  eat()
{
System.out.println("humans are eat veg and non-veg");
}

4. final in method

Not allowed in interface in final , final mean can not override , interface the main goal is override/implement  to from interface to implemented class . final keyword  can not to use method like abstract, default...etc. Only abstract, default, static, private (from Java 9+) are allowed

//NOW SEE Variables

interface Fruits
{
String fruitName = "Mango";

//above equal to below
public static final String fruitName = "Mango";
}

// you can not declare in interface:-

- private,protected variable not allowed.
- non-static variable(instance field) and method(with body)   not allowed , because you can not create object in interface. 
- protected (only accessible for within  package or subclass,  not for globally) not to allowed to use in interface method,interface method  must to be  access globally   mean like public contract, so protected not to allowed method and variable.
- one more recap , you can not use in  some access  and non access modifier like protected and final and in the method. 




q.1 can we change value of interface variable?
NO, because , by default set final like constant ,can not change the value.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;java 7 and before:&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;An interface only contain:&lt;br&gt;
abstract methods.&lt;br&gt;
Constant(public static final)&lt;br&gt;
This means 100% abstraction- no method in a  body&lt;/p&gt;

&lt;p&gt;&lt;u&gt;java8 and later:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;java 8 introduced:&lt;/li&gt;
&lt;li&gt;default method(with method body)&lt;/li&gt;
&lt;li&gt;&lt;p&gt;static  methods(with method body)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;so interface  now included concrete  method ,so interface not anymore 100% abstraction, like abstract classes(Not 100% abstraction) &lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Supports default and static methods.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;java 9 &lt;/p&gt;

&lt;p&gt;you can write private methods inside of  interface.&lt;/p&gt;

&lt;p&gt;&lt;u&gt;Key points:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Interface and inside of method(in-completed method) is implicitly abstract , you do not need mention.&lt;/li&gt;
&lt;li&gt;Interface not to allowed to create object.&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interface does not contain any constructor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interface methods are by default abstract and public&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  -  class can extend only one class. Class can implements more than one interface at a time with (,). interface extends more then one interface.
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Interface attributes(fields or variable) are by default public, static and final =&amp;gt; constant&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstract class can implement interface methods&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;interface can not implement or extend  a abstract class or normal class.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All fields in a interface are public, static, and final by default.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;All methods in an interface are public and abstract by default (except default, static, and private methods)&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;.&lt;br&gt;
Rules for overriding methods from interface:-&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Method Signature Must Match&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;method name, parameter list , return type must match &lt;/li&gt;
&lt;li&gt;you can return same type or sub type(covariant return)
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface Parent {
    Number getMoney(); // return type is Number
}

class Child implements Parent {
    public Integer getMoney() { // Integer is a subtype of Number 
        return 1000;
    }
}


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;2.Checked Exceptions(must to handle ,you can not ignore) Must Be Compatible(only throw same or child exception not unrelated exception):&lt;/p&gt;

&lt;p&gt;Interface method throws a checked exception (must be handled, cannot ignore).&lt;br&gt;
When a class overrides that method, it can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Throw the same exception &lt;/li&gt;
&lt;li&gt;    Throw a subclass of that exception &lt;/li&gt;
&lt;li&gt;    Throw nothing (no exception) &lt;/li&gt;
&lt;li&gt;     But cannot throw a new or unrelated checked exception.
&lt;/li&gt;
&lt;/ul&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;we will see example in Exception handling
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ol&gt;
&lt;li&gt;Implementation Class Can Be Abstract&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If class implemets a interface but does not override the abstract method , you can set abstract keyword in class.&lt;/p&gt;

&lt;p&gt;Example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;interface GrandParent {
    void skill();
}

abstract class Parent implements GrandParent {
    // no implementation of skill() — that's okay because Parent is abstract
}

class Child extends Parent  {
    public void skill() {
        System.out.println("Child implemented method");
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>programming</category>
      <category>java</category>
    </item>
    <item>
      <title>Abstraction</title>
      <dc:creator>Prasanth</dc:creator>
      <pubDate>Sun, 15 Jun 2025 15:48:03 +0000</pubDate>
      <link>https://forem.com/prasanth362k/abstraction-1npb</link>
      <guid>https://forem.com/prasanth362k/abstraction-1npb</guid>
      <description>&lt;p&gt;What is Abstraction ?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Abstraction means hiding internal details and showing only the essential features to the user.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;(or)&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Abstraction in java is process of  hiding implementation details and showing only  functionality.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;abstract is a  keyword ,it is non-access modifier , used classes and methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;It tells what an object does, not how it does it.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Achieved using:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Abstract classes.( 0% to 100% partial Abstraction and can have both abstract and normal methods )&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Interface(100% Abstraction -&amp;gt; all methods are abstract by default until java 7). use  interface for multiple inheritance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;From java 8 onward, interface can have(Interface gives 100% abstraction (before Java 8).):&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;default methods(with body)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;static methods, so interface not always 100% abstract anymore.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Abstract Class:-&lt;/u&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt; A class with the  abstract keyword is called an abstract class.&lt;/li&gt;
&lt;li&gt;It can have:&lt;/li&gt;
&lt;/ol&gt;

&lt;ul&gt;
&lt;li&gt;Abstract method(without body)&lt;/li&gt;
&lt;li&gt;Concrete methods(with body)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Abstract classes can have:&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt; Abstract methods&lt;/li&gt;
&lt;li&gt;    Concrete (regular) methods&lt;/li&gt;
&lt;li&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Constructors (including parameterized constructors
&lt;/code&gt;&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If  a class has even one abstract method , that class must be abstract.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;abstract class  restricted to Cannot create objects of an abstract class. but subclass extends the  abstract class, and you create an object of subclass, the constructor of  the abstract class will still run. because  sub class object is created ,so the abstract class constructor run first after own class constructor.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If child class(any class)  inherit(extend) super of  abstract class  must to implement its abstract methods otherwise that class also abstract class and that class can not create object.&lt;br&gt;
abstract  class can have static and final methods.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Abstraction class can contain fields(variable) it helps to initialized through constructors.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Abstract Method:-&lt;/u&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Declared with the abstract keyword.&lt;/li&gt;
&lt;li&gt;Abstract method  no body , just the method name and a semicolon.&lt;/li&gt;
&lt;li&gt;That class that contain abstract method it must also be abstract.&lt;/li&gt;
&lt;li&gt;Any class that inherits the abstract class:
must implement the abstract method (must override abstract method )other wise  declare the class also abstract.&lt;/li&gt;
&lt;li&gt;you can not create an object of an abstract class.&lt;/li&gt;
&lt;li&gt; A subclass  must override all  abstract methods of an abstract class.&lt;/li&gt;
&lt;li&gt;Abstract method can have access modifiers like public, protected ,or default(no modifier).&lt;/li&gt;
&lt;li&gt;But not private ,because the subclass needs access to override it.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;u&gt;Example:-&lt;/u&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract class Father
{
abstract void  skill(); //abstract method
}


class Child extends Father

void skill(){
System.out.println("I Drawing well the picture ");
}
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example:-&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;abstract class Father
{
abstract void  skill(); //abstract method
}


class Child extends Father
{
    // Did NOT implement skill()
}
// compile time error came 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;u&gt;Example:-&lt;/u&gt;&lt;/p&gt;

&lt;p&gt;when you send an email , you don not know what happens behind  the  scenes(protocols,servers). you just type, enter an address, and click send.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Abstraction is -&amp;gt; you see what it does, not how it works.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;How many abstract methods can an abstract class have?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;0,1 or many in abstract class.&lt;/li&gt;
&lt;li&gt;A abstract method may or may not abstract method even  0  abstract method allowed. &lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Can we use non-access modifiers like static, final, abstract together?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;you can combine abstract with public ,protected.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;can not use final and abstract and static method can to be abstract.&lt;/p&gt;

&lt;p&gt;Can abstract methods have parameters and return types?&lt;/p&gt;

&lt;p&gt;yes.&lt;/p&gt;

&lt;p&gt;Can we override an abstract method with the same parameters?&lt;/p&gt;

&lt;p&gt;yes. that is required , method signature must match.&lt;/p&gt;

&lt;p&gt;Can an abstract class have an inner class?&lt;/p&gt;

&lt;p&gt;Yes. Abstract classes can have inner classes&lt;/p&gt;

&lt;p&gt;Why Interface provides 100% Abstraction (before Java 8)&lt;/p&gt;

&lt;p&gt;Why Abstract Class Cannot Achieve 100% Abstraction?&lt;/p&gt;

&lt;p&gt;Above 2 question ans in command section&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package abstraction;

abstract public class Vehicle {

    // you can use fields private use to getter/setter method (abstraction +Encapsulation)
    String brand;
    int wheels =4;
    final int speedLimit =120;



    //constructor in abstract class
    Vehicle(String brand)
    {
        this.brand = brand;
        System.out.println("Vehicle constructor called");
    }

    // abstract method (must be implemeted in child class)

    // abstract method can use public ,default(no modifer),proctecte
    // can not use abstract method in private,static,final
    abstract void start();

    abstract void carWashing();

    //concreate method

    void stop()
    {
        System.out.println("Vehicle stopped");
    }
    final void fueltype()
    {
        System.out.println("car Fuel type Petrol or Diesel");
    }

    static void info()
    {
        System.out.println("Vehicle are used for transport");
    }
    public static void main(String[] args) {

        //Vehicle vehicle1 = new Vehicle();  object can not created in abstract class in core concept java incomplemetd  method in class can not create object .
    }
}



// child class



package abstraction;

abstract public class Vehicle {

    // you can use fields private use to getter/setter method (abstraction +Encapsulation)
    String brand;
    int wheels =4;
    final int speedLimit =120;



    //constructor in abstract class
    Vehicle(String brand)
    {
        this.brand = brand;
        System.out.println("Vehicle constructor called");
    }

    // abstract method (must be implemeted in child class)

    // abstract method can use public ,default(no modifer),proctecte
    // can not use abstract method in private,static,final
    abstract void start();

    abstract void carWashing();

    //concreate method

    void stop()
    {
        System.out.println("Vehicle stopped");
    }
    final void fueltype()
    {
        System.out.println("car Fuel type Petrol or Diesel");
    }

    static void info()
    {
        System.out.println("Vehicle are used for transport");
    }
    public static void main(String[] args) {

        //Vehicle vehicle1 = new Vehicle();  object can not created in abstract class in core concept java incomplemetd  method in class can not create object .
    }
}



&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
    </item>
  </channel>
</rss>
