Spring Framework Versions and Release Dates

Version Release Date
6.0.x 2022-11-22
5.0.x 2017-10-24
4.3.x 2016-06-10
4.2.x 2015-07-31
4.1.x 2014-09-14
4.0.x 2013-12-12
3.2.x 2012-12-13
3.1.x 2011-12-13
3.0.x 2009-12-17
2.5.x 2007-12-25
2.0.x 2006-10-04
1.2.x 2005-05-13
1.1.x 2004-09-05
1.0.x 2003-03-24

Section 1: Setup (XML Configuration)

Steps to Create Hello Spring:

  1. Investigate Spring Boot:

  2. Project Setup:

  3. Create a POJO Class (e.g., Employee.java):

    package com.test;
    
    public class Employee {
       private String name;
    
       public String getName() {
          return name;
       }
    
       public void setName(String name) {
          this.name = name;
       }
    
       public void displayName() {
          System.out.println(name);
       }
    }
    
    
  4. Create an XML Configuration File (e.g., beans.xml):

    <?xml version="1.0" encoding="UTF-8"?>
    <beans xmlns="<http://www.springframework.org/schema/beans>"
       xmlns:xsi="<http://www.w3.org/2001/XMLSchema-instance>"
       xsi:schemaLocation="<http://www.springframework.org/schema/beans>
       <http://www.springframework.org/schema/beans/spring-beans-4.3.xsd>">
    
       <bean id="employee" class="com.test.Employee">
          <property name="name" value="test spring"></property>
       </bean>
    </beans>
    
    
  5. Create Main Class (e.g., Customer.java):

    package com.test;
    
    import org.springframework.context.ApplicationContext;
    import org.springframework.context.support.ClassPathXmlApplicationContext;
    
    public class Customer {
       public static void main(String[] args) {
          ApplicationContext context = new ClassPathXmlApplicationContext("beans.xml");
          Employee obj = (Employee) context.getBean("employee");
          obj.displayName();
       }
    }
    
    
  6. Include Dependencies:

    Section 2: What is Spring Framework, and Why Choose It?

    Spring is a comprehensive framework that provides a set of classes, abstracting away boilerplate logic in Java EE development. It simplifies the coding process by handling repetitive tasks, allowing developers to focus on business logic. Here's why you should choose Spring:

    Simplifying Development

    In a simple JDBC application, developers are traditionally responsible for tasks like loading the driver class, creating connections and statements, handling exceptions, creating queries, executing queries, and closing connections. Spring abstracts away this boilerplate code, enabling developers to write cleaner, more concise code.

    Advantages Over Struts

    While Struts focuses on web aspects and is invasive in nature, Spring offers several advantages:

    1. Noninvasive Nature:
      • Spring doesn't require extending classes or implementing interfaces, making it noninvasive to your code.
    2. Versatility:
      • It seamlessly integrates with existing technologies in your project, making it versatile.
    3. End-to-End Project Development:
      • Spring supports the development of all modules, including business layer and persistence layer.
    4. Lightweight:
      • Developers can focus on specific modules without the need to learn the entire Spring framework.
    5. Dependency Injection:
      • Spring supports dependency injection, simplifying component interactions and testing.
    6. Support for Multiple Project Types:
      • Spring is adaptable to various project types, including core Java applications, web applications, distributed applications, and enterprise applications.
    7. Aspect-Oriented Programming (AOP):
      • Spring supports AOP, allowing for the implementation of cross-cutting concerns.

    Relationship with Struts and J2EE

    Spring is considered an alternative to Struts but is not a replacement for J2EE API. Spring's internal classes may use J2EE API classes, emphasizing its compatibility rather than replacement. The vast Spring framework is modular, with important modules such as:

    1. Spring Core
    2. Spring JDBC
    3. Spring AOP
    4. Spring Transaction
    5. Spring ORM
    6. Spring MVC

    Each module is independent, except for the Spring Core, allowing developers to choose and use specific modules based on project requirements.