Beans that do not need to be referenced elsewhere can be defined anonymously
This bean is identified (has an id) and can be accessed to inject it into another bean
<bean id="exampleBean" class="org.example.ExampleBean">
<property name="anotherBean" ref="someOtherBean" />
</bean>
This bean is anonymous (no id)
<bean class="org.example.ExampleBean">
<property name="anotherBean" ref="someOtherBean" />
</bean>
This bean is identified (has an id) and can be accessed to inject it into another bean
<bean id="exampleBean" class="org.example.ExampleBean">
<property name="anotherBean" ref="someOtherBean" />
</bean>
This bean is anonymous (no id)
<bean class="org.example.ExampleBean">
<property name="anotherBean" ref="someOtherBean" />
</bean>
Posted in: