Spring Framework Basics: Core Concepts, Modules, Dependency Injection, Beans, Annotations, AOP, MVC, and Data Access

An extensive overview of the Spring Framework covering its core concepts, version features, lightweight architecture, IoC container, dependency injection methods, bean definitions and scopes, configuration styles, annotation usage, AOP principles, MVC workflow, data access mechanisms, and related implementation details with code examples.

Java Captain
Java Captain
Java Captain
Spring Framework Basics: Core Concepts, Modules, Dependency Injection, Beans, Annotations, AOP, MVC, and Data Access

Spring Framework is an open‑source, lightweight, and loosely‑coupled application framework that simplifies Java development by providing a layered architecture, container management, and integration with other technologies such as Hibernate and EJB.

Core Modules

Spring Core, Spring Bean, SpEL, Spring Context

Data Access/Integration: JDBC, ORM, OXM, JMS, Transaction

Web: Web, Web‑Servlet, Web‑Socket, Web‑Portlet

AOP, Instrumentation, Test, Messaging, Aspects

Configuration Files

Spring beans can be defined using XML, Java annotations, or Java‑based @Configuration classes.

<bean id="studentbean" class="org.edureka.firstSpring.StudentBean">
  <property name="name" value="Edureka"/>
</bean>

Annotation‑based configuration requires enabling <context:annotation-config/> in the XML or using @ComponentScan in Java config.

@Configuration
public class StudentConfig {
    @Bean
    public StudentBean myStudent() {
        return new StudentBean();
    }
}

Dependency Injection (IoC)

The IoC container creates, configures, and manages bean lifecycles using constructor or setter injection. Spring supports two container types: BeanFactory and ApplicationContext.

Example of a simple factory pattern used in IoC:

interface Fruit { void eat(); }
class Apple implements Fruit { public void eat() { System.out.println("Apple"); } }
class Orange implements Fruit { public void eat() { System.out.println("Orange"); } }
class Factory {
    public static Fruit getInstance(String className) {
        Fruit f = null;
        try { f = (Fruit) Class.forName(className).newInstance(); }
        catch (Exception e) { e.printStackTrace(); }
        return f;
    }
}

Bean Scopes

Singleton

Prototype

Request

Session

Global‑session

Annotations

@Component, @Controller, @Service, @Repository

@Autowired, @Qualifier, @Required, @Scope

@Configuration, @Bean, @ComponentScan

@Aspect, @Before, @After, @Around, @AfterReturning, @AfterThrowing, @Pointcut

@RequestMapping, @ResponseBody, @PathVariable

Enabling annotation processing is done via <context:annotation-config/> or the equivalent Java configuration.

AOP

Aspect‑Oriented Programming separates cross‑cutting concerns such as logging and security. Key concepts include Aspect, Advice (Before, After, Around, etc.), Pointcut, JoinPoint, and weaving. Spring AOP uses dynamic proxies (JDK or CGLIB) while AspectJ uses static weaving.

MVC Workflow

The DispatcherServlet receives HTTP requests, uses HandlerMapping to locate the appropriate controller, invokes it via a HandlerAdapter, processes the request data (conversion, validation), and returns a ModelAndView. A ViewResolver then renders the view and sends the response back to the client.

Data Access

Spring abstracts data access through JDBC templates (JdbcTemplate, NamedParameterJdbcTemplate, etc.) and supports ORM frameworks like Hibernate, iBatis, JPA, JDO, and OJB. Transaction management can be programmatic or declarative using annotations or XML.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

JavaaopMVCdependency-injectionSpring Framework
Java Captain
Written by

Java Captain

Focused on Java technologies: SSM, the Spring ecosystem, microservices, MySQL, MyCat, clustering, distributed systems, middleware, Linux, networking, multithreading; occasionally covers DevOps tools like Jenkins, Nexus, Docker, ELK; shares practical tech insights and is dedicated to full‑stack Java development.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.