<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
    xmlns:p="http://www.springframework.org/schema/p" xmlns:mongo="http://www.springframework.org/schema/data/mongo"
    xsi:schemaLocation="
       http://www.springframework.org/schema/beans 
       http://www.springframework.org/schema/beans/spring-beans-3.2.xsd
       http://www.springframework.org/schema/data/mongo
       http://www.springframework.org/schema/data/mongo/spring-mongo-1.0.xsd
       http://www.springframework.org/schema/context 
       http://www.springframework.org/schema/context/spring-context-3.2.xsd"
>
    <context:annotation-config/>
    
    <mongo:mongo id="mongo" host="localhost" />
    
    <mongo:db-factory id="mongoDbFactory" dbname="test" mongo-ref="mongo" />
    
    <bean id="gridFsTemplate" class="org.springframework.data.mongodb.gridfs.GridFsTemplate">
        <constructor-arg ref="mongoDbFactory" />
        <constructor-arg ref="mongoConverter" />
    </bean>

    <bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
        <constructor-arg ref="mongoDbFactory"/>
        <constructor-arg ref="mongoConverter" />
    </bean>

    <bean class="org.springframework.dao.annotation.PersistenceExceptionTranslationPostProcessor"/>

    <mongo:repositories base-package="org.baeldung.repository" mongo-template-ref="mongoTemplate"/>

    <bean class="org.baeldung.event.CascadeSaveMongoEventListener">
    </bean>

    <mongo:mapping-converter id="mongoConverter" base-package="org.baeldung.converter">
        <mongo:custom-converters base-package="org.baeldung.converter"/>
    </mongo:mapping-converter>

</beans>