Dependency Injection Summary
Summary of dependency injection in Spring Boot.
- All the necessary dependencies are handed over to the object by spring.
- It frees the object from resolving the dependencies.
- It greatly simplifies the code and improves code reusability.
- It promotes programming to interfaces.
- Conceals implementation details of dependencies.
- It improves testability.
- Dependencies easily stubbed out for unit testing.
- Allows for centralized control over object lifecycle.
Ways to achieve dependency Injection.
- Using constructor
- Using setter method
- Using @Autowired annotation.
Related Articles
Using scp to copy files
Copy file from local pc to remote server scp <filename> <useronremotesystem>@<ipaddressofremotesystem>:<remotedirpath>/<remotefilename> scp mytext.txt user2@192.168.1.25:/home/user2/mytext.txt Copy file from remote server to local pc…
Update database with Fluent API approach
Dependency Injection Summary 0 Comments Written by Buddhi2018-08-05 public Book book(Long bookId, Book book) { return bookRepository.findById(bookId). map(foundBook -> { foundBook.setName(book.getName()); foundBook.setDescription(book.getDescription());…
Thread Communication in Java
Dependency Injection Summary 0 Comments Written by Buddhi2018-08-05Interthread communication in Java package org.example; public class ThreadCommunication { private static final int DATA_SIZE = 1000; public static void main(String[] args) { //common channel for…