Spring Beginner Tutorial: Dependency Injection Part 1 – ExampleRunner

What is Dependency Injection? – Part 1

This is the first in a series of blog posts that I’m putting together for developers who are beginning to work with Spring. This post sets us up to understand a basic principle of Spring – Dependency Injection.

To start us off, I’ve created a simple class with a main method. As you can see in the snippet below, all the main method does is instantiate an ExampleRunner class and call the run() method on it. This is what we’ll use to kick off the examples that follow.

Find the snippet below. You can see the full version of this example at my Spring Beginner Tutorial github repo:

In my next post we’ll dig into the fundamentals of Dependency Injection. Sometimes people call it Inversion of Control.


This is the introductory blog post that sets us up for the rest of the tutorial. It describes a simple class that allows us to execute code where we can view the examples that follow.

I hope you’ll follow along and find the tutorial helpful. I’ve been doing Spring for several years now, and I’ve felt that a simple tutorial for beginners is more than overdue. As always, send me your feedback and comments.

Leave a Reply

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