---
title: "Discussion on \"SOLID Principles in Spring Boot: A Comprehensive Guide\" | Hashnode"
description: "Discussion on \"SOLID Principles in Spring Boot: A Comprehensive Guide\". Learn about the SOLID principles of software development and how to implement them in Spring Boot with code examples and detailed explanations."
url: "https://hashnode.com/posts/solid-principles-in-spring-boot/63e77d3200ce505f786e81f1"
---

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

Discussion

# [SOLID Principles in Spring Boot: A Comprehensive Guide](https://amrtechuniverse.com/solid-principles-in-spring-boot?utm_source=hashnode&utm_medium=feed)

Learn about the SOLID principles of software development and how to implement them in Spring Boot with code examples and detailed explanations.

Feb 11, 2023 · 5 min read · amrtechuniverse.com  
Read the article

-   [#solid-principles](https://hashnode.com/tag/solid-principles)
-   [#springboot](https://hashnode.com/tag/springboot)
-   [#java](https://hashnode.com/tag/java)
-   [#spring](https://hashnode.com/tag/spring)
-   [#spring-framework](https://hashnode.com/tag/spring-framework)

## Written by

[Amr Khaled](https://hashnode.com/@amrkh97)

@amrkh97 · Cairo, Egypt

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

An Enthusiastic Software Engineer

An experienced Software engineer with extensive knowledge in Fullstack development ( Java - Angular 8+ ) and Data Science.

## Responses 1

Markdown supported · ⌘↵ to post

[JS Rammohan](https://hashnode.com/@Ram1603)

[Apr 3, 2024](https://hashnode.com/posts/solid-principles-in-spring-boot/63e77d3200ce505f786e81f1/comment/660cafe4e3f49ff8760c16aa)

First of all, thanks for the detailed explanation about solid principles usage. I have a question about how to initialize runtime object of PaypalPaymentService for Rest Controller in DIP example.

[Amr Khaled](https://hashnode.com/@amrkh97)

[Apr 21, 2024](https://hashnode.com/posts/solid-principles-in-spring-boot/63e77d3200ce505f786e81f1/comment/660cafe4e3f49ff8760c16aa#reply-6624d42bdf20e2b36f0001bc)

Thank you so much, and sorry for the very late reply.

You can initialize it in multiple ways:

1- Constructor injection:

private final PaymentService creditCardPaymentService; private final PaymentService payPalPaymentService;

@Autowired public PaymentController(CreditCardPaymentService creditCardPaymentService, PayPalPaymentService payPalPaymentService) { this.creditCardPaymentService = creditCardPaymentService; this.payPalPaymentService = payPalPaymentService; }

2- With qualifiers:

@Qualifier("payPalPaymentService") public class PayPalPaymentService extends PaymentService {

and then in your controller or other service:

private final PaymentService creditCardPaymentService; private final PaymentService payPalPaymentService;

@Autowired public PaymentController(@Qualifier("creditCardPaymentService") PaymentService creditCardPaymentService, @Qualifier("payPalPaymentService") PaymentService payPalPaymentService) { this.creditCardPaymentService = creditCardPaymentService; this.payPalPaymentService = payPalPaymentService; }
