Creating an XML configuration file

In the section on Java-based configuration, we had created an AppConfig class annotated with the @Configuration annotation. Similarly, for XML-based configuration, we will now create an applicationContext.xml file rooted with a <beans> element. The following simplest possible example shows the basic structure of XML-based configuration metadata:

Following is the applicationContext.xml file:

    <?xml version="1.0" encoding="UTF-8"?> 
    <beans xmlns="http://www.springframework.org/schema/beans" 
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
     xsi:schemaLocation="http://www.springframework.org/schema/beans   
http://www.springframework.org/schema/beans/spring-beans.xsd"> <!-- Configuration for bean definitions go here --> </beans>

The preceding XML file is a configuration file of the application which contains the details on bean definitions. This file is also loaded by the XML-flavored implementation of ApplicationContext to create beans for your application. Let's see how you can declare the TransferService, AccountRepository and TransferRepository beans in the preceding XML file.