Sobes.tech
Junior — Middle

How can you set up Bean configurations using an XML file in Spring?

sobes.tech AI

Answer from AI

In Spring, bean configurations can be specified in an XML file using the <bean> tag. It indicates the class, properties, and dependencies.

Example of defining a bean with a property:

<bean id="myBean" class="com.example.MyClass">
    <property name="propertyName" value="propertyValue" />
</bean>

To set a dependency on another bean:

<bean id="dependentBean" class="com.example.DependentClass">
    <property name="myBean" ref="myBean" />
</bean>

Thus, the configuration described in XML is used by the Spring container to create and configure objects.

How can you set up Bean configurations using an XML… - sobes.tech