Autowiring, Autowiring Modes - byName, byType & constructor. Spring-Ep:5

Опубликовано: 01 Август 2026
на канале: Ajoy Debnath
100
8

Hi,
Hope you are all doing great. Let's learn together.
Join Telegram: 📲 https://t.me/contactajoydebnath

Timeline
0:00 Introduction
01:40 Dependency Injection By "ref" attribute
12:11 autowire="byName"
17:30 autowire="byType"
24:45 autowire="constructor"
29:36 autodetect
33:16 autowire="no"

Note:
Spring is a lightweight framework. It was developed by Rod Johnson in 2003. Spring framework makes the easy development of JavaEE applications.

Document Link -
https://docs.google.com/document/d/14...

Spring Video Links
IOC, Dependency Injection, IOC Container, Coupling. --    • IOC,Dependency Injection,IOC Container,Cou...  
IOC Container, BeanFactory, Important APIs, Lazy & Eager Loading. --   • IOC Container, BeanFactory, Lazy & Eager L...  
Bean Scope, Singleton Scope, and Prototype Scope. --    • Bean Scope, Singleton Scope, and Prototype...  
Autowiring, Autowiring Modes - byName, byType & constructor. --    • Autowiring, Autowiring Modes - byName, byT...  
@Configuration, @Bean, @Component, @ComponentScan in Spring. --   • @Configuration, @Bean, @Component, @Compon...  
What if we remove the @Configuration annotation in Spring? --    • What if we remove the @Configuration annot...  
Spring JDBCTemplate, JDBC, Statement, and PreparedStatement. --    • Spring JDBCTemplate, JDBC, Statement and P...  
JDBCTemplate, RowMapper, ResultSetExtractor, BeanPropertyRowMapper Spring. --    • JDBCTemplate, RowMapper,ResultSetExtractor...  
Model-View-Controller(MVC), Spring MVC. --    • Model-View-Controller(MVC), Spring MVC. Sp...  
Spring MVC with JSP (Java server Page). --    • Spring MVC with JSP (Java server Page).  S...  
Spring MVC with JSP (Java server Page). --    • Spring MVC with JSP (Java server Page). Sp...  

Java Video Links
Exception, Exception Hierarchy, Call Stack, Propagation. --    • Exception, Exception Hierarchy, Call Stack...  
Exception, try, catch, finally. --    • Exception, Propagation try, catch, finally...  
Exception, Custom Exception, throw, throws. --    • Exception, Custom Exception, throw, throws...  
Object Cloning, Shallow Copy, and Deep Copy. --    • Object Cloning, Shallow Copy, and Deep Cop...  
How to create an Immutable class in Java? Immutable Design Pattern. --    • How to create Immutable class in Java? Imm...  
Factory Method Design Pattern. --    • Factory Method Design Pattern. Bengali-Ep:...  
Stream API: Intermediate & Terminal operations. --    • Stream API: Intermediate & Terminal operat...  
Stream API: Intermediate & Terminal operations. --    • Stream API : Intermediate & Terminal opera...  
Guide To Java 8 Optional Class. Part-I. --    • Guide To Java 8 Optional Class. Part-I. Be...  
Guide To Java 8 Optional Class. Part-II. --    • Guide To Java 8 Optional Class. Part-II Be...  
Access Modifier. Private, Public, Default, Protected. --    • Access Modifier. Private, Public, Default,...  
Collection Framework. --    • Collections Framework, Collection & Iterat...  
ArrayList, ListIterator, How It Works Internally. --    • ArrayList, ListIterator, How It Works Inte...  
LinkedList, Methods & How It Works Internally in Java. --    • LinkedList, Methods & How It Works Interna...  
HashSet & How It Works Internally in Java. --    • HashSet & How It Works Internally in Java....  
HashSet, Its Methods & How It Works Internally in Java. --    • HashSet, Its Methods & How It Works Intern...  
Singleton Design Pattern in Java. Early & Lazy Instantiation. --    • Singleton Design Pattern Java. Early & Laz...  
Singleton Pattern. Lazy Instantiation for Multiple Threads.Part-2. --    • Singleton Pattern. Lazy Instantiation for ...  
Lambda Expression, Functional Interfaces, Anonymous Class. --    • Lambda Expression, Functional Interfaces, ...  

Like, Comment, Share, and Subscribe.
Thank you again.

STS Link:
https://spring.io/tools

JDK Link:
https://www.oracle.com/java/technolog...

To download spring jars
https://repo.spring.io/ui/native/rele...

Spring IOC Container
Spring IoC Container is the core of Spring Framework. It creates the objects, configures and assembles their dependencies, and manages their entire life cycle. The Container uses Dependency Injection(DI) to manage the components that make up the application. It gets the information about the objects from a configuration file(XML) or Java Code or Java Annotations and Java POJO class. These objects are called Beans.

Bean
In Spring, the objects that are managed by the Spring IoC container are called Beans.

Autowiring
We specify the beans that will be injected into other beans using the “ref” attribute but the spring framework provides auto-wiring features too where we don’t need to provide bean injection details explicitly.
Autowiring can't be used to inject primitive and string values. It works with reference only.

Autowiring Modes

autowire="no"
It is the default auto-wiring mode. It means no auto-wiring by default.

autowire="byName"
The byName mode injects the object dependency according to the name of the bean. In such cases, the property name and bean name must be the same. It internally calls the setter method.

autowire="byType"
The byType mode injects the object dependency according to type. So property name and bean name can be different. It internally calls the setter method.

autowire="constructor"
It injects the required dependencies by invoking the constructor. It works similarly to the “byType” mode but it looks for the class type of the constructor arguments. If none or more than one bean is detected, then it throws an error, otherwise, it autowires the “byType” on all constructor arguments.