Spring Dependency Injection using Annotations

The tutorial describes performing Spring Dependency Injection using Annotations.

1. Project Setup

Lets create a simple maven project with the below pom.xml

2. Code Interface

Code an Interface say

3. Code Implementation

Add an Implementation to the above Interface

4. Configure Class & Declare Bean

Lets create a Configuration Class and declare the above bean

5. Main Program

The main program to test would be

6. Output:

Spring Dependency Injection with Annotations Output


7. Project Structure:

Spring DI with Annotations Project Structure

Project Structure


I hope this has been useful for you and I’d like to thank you for reading. If you like this article, please leave a helpful comment and share it with your friends.


  1. By Vengat


    • By Manjunath


Leave a Reply

Your email address will not be published. Required fields are marked *