In Spring wiring means configuration the bean dependency if any. It may be done explicitly by hard-coding the code in XMl file or implicitly by mentioning the required type of autowiring process in the XML file. Autowiring process is further divided into two category :
1. XML based Auto-Wiring process.2. Annotation based Auto-Wiring process.
Explicitly wiring the dependencies in the XML is otherwise also called as XML based Explicitly Wiring.
XML based Auto-Wiring process
There are four type by which we can achieve XML based autowiring, i.e
1. byName autowiring
2. byType autowiring
3. constructor autowiring
4. Autodetect autowiring
All the above auto-wiring process can be done by writing the respective values to the autowire attribute in the XML file. Like this,
<bean id=" " class=" " autowire="xxx" />
xxx can be :a. byName b. byType c. constructor d. autodetect
Annotation based Auto-Wiring
There are two annotations facility available in the Spring for bean dependency detection and injection. Injecting the bean through annotation based wiring is knows as Field Injection.
We are writing annotation with the field attributes that why it is named as Field Injection.
The two types of Annotation based Auto-Wiring are :
1. @Autowired annotation.
2. @Resource annotation.
ReplyDeletenice article for beginners.thank you.
java tutorial
spring tutorial