Annotated Dependency Injection / Inversion of Control (DI / IoC) in Spring 3 Web MVC using Netbeans

This tutorial will detail how to insert services and components (Dependency Injection) into a Spring 3 Web MVC Netbeans application.

The process used is Dependency Injection (DI) or Inverse of Control (IoC) whereby Spring will instantiate (or inject) certain components at runtime rather than at having them initiated at compile time.  This provides a highly decoupled design which facilitates ‘change’ more easily. Importantly, it also makes comprehensive Unit Testing (with Mock Objects) much easier to achieve. IoC is a conventional design pattern.

This tutorial is quite comprehensive in that it will simulate CRUD operations on ‘Person’ objects. For simplicity, it does not used a database, data will be put stored in the ‘HttpSession’ object instead.

The code is available for download at the bottom of this page. Continue reading “Annotated Dependency Injection / Inversion of Control (DI / IoC) in Spring 3 Web MVC using Netbeans”