---
title: "Discussion on \"Spring Basics - Dependency Injection\" | Hashnode"
description: "Discussion on \"Spring Basics - Dependency Injection\". In this blog post we’ll learn about Dependency Injection (DI) and how to use it. We can do this using constructor and setter injection."
url: "https://hashnode.com/posts/spring-basics-dependency-injection/61f98ee2e0502911a6f10cd5"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [Spring Basics - Dependency Injection](https://maxwelldemaio.hashnode.dev/spring-basics-dependency-injection?utm_source=hashnode&utm_medium=feed)

In this blog post we’ll learn about Dependency Injection (DI) and how to use it. We can do this using constructor and setter injection.

Feb 1, 2022 · 5 min read · maxwelldemaio.hashnode.dev  
Read the article

-   [#java](https://hashnode.com/tag/java)
-   [#spring](https://hashnode.com/tag/spring)
-   [#coding](https://hashnode.com/tag/coding)

## Written by

[Max DeMaio](https://hashnode.com/@maxdemaio)

@maxdemaio

  
[View profile](https://hashnode.com/@maxdemaio)

Passionate about software, language, and business

Passionate about business, language, and computer science.

## Responses 1

Markdown supported · ⌘↵ to post

[Shai Almog](https://hashnode.com/@talktotheduck)

[Feb 2, 2022](https://hashnode.com/posts/spring-basics-dependency-injection/61f98ee2e0502911a6f10cd5/comment/61fa0eb443e34d1181695e29)

Why XML and not annotations?

[Max DeMaio](https://hashnode.com/@maxdemaio)

[Feb 2, 2022](https://hashnode.com/posts/spring-basics-dependency-injection/61f98ee2e0502911a6f10cd5/comment/61fa0eb443e34d1181695e29#reply-61fa1084e0502911a6f11609)

Hi there! I chose XML configuration solely for small tutorial purposes. I'm able to explicitly show constructor/setter injection. It gives a good visual on how Spring configures metadata into its managed objects.

But, in future Spring posts I'll be ditching XML for annotation-based configs :D
