Auto wiring is method of creating an instance of an object and "by concept" injecting that instance on a specific class that uses it. We need not to inject manually in xml as we did in address in student in xml automatically it detects where to get injected.
Now we will see examples with auto wiring. This can be achieved in below ways.
By using autowire attribute in xml
Try below changes to understand this:
<bean id="address" class="com.javabykiran.Address">
<property name="landmark" value="park plaza"></property>
</bean>
<bean id="address1" class="com.javabykiran.Address">
<property name="landmark" value="park plaza"></property>
</bean>
<bean id="stu" class="com.javabykiran.Student" scope="singleton" autowire="byName">
<property name="age" value="30"></property>
<property name="mobileNos">
<list>
<value>8888809416</value>
<value>9552343698</value>
</list>
</property>
</bean>
ByName means address from student is matching with address bean id from xml so it will be injected. In our case to address and address1 both matching but exact matching name will be injected (address not address1).
Now try byType for this change xml like this we may see errors due to this. As Types are matching for both beans address and address1 so remove one it will start working.