<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:mongo="http://www.springframework.org/schema/data/mongo"
       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
       http://www.springframework.org/schema/data/mongo http://www.springframework.org/schema/data/mongo/spring-mongo.xsd">

  <bean class="org.springframework.data.mongodb.core.TestMongoConfiguration"/>
  
  <mongo:db-factory dbname="database"/>

  <bean id="mappingConverter1" class="org.springframework.data.mongodb.core.convert.MappingMongoConverter">
  	<constructor-arg ref="mongoDbFactory" />
    <constructor-arg ref="mappingContext" />
    <property name="customConversions" ref="conversions" />
  </bean>

  <bean id="mappingContext" class="org.springframework.data.mongodb.core.mapping.MongoMappingContext">
  	<property name="simpleTypeHolder">
  		<bean factory-bean="conversions" factory-method="getSimpleTypeHolder" />
  	</property>
  </bean>
  
	<bean id="conversions" class="org.springframework.data.mongodb.core.convert.CustomConversions">
		<constructor-arg>
			<list>
				<bean class="org.springframework.data.mongodb.core.PersonReadConverter" />
				<bean class="org.springframework.data.mongodb.core.PersonWriteConverter" />
			</list>
		</constructor-arg>
	</bean>

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

  <mongo:mapping-converter id="mappingConverter2" base-package="org.springframework.data.mongodb.core.mapping">
      <mongo:custom-converters>
        <mongo:converter>
          <bean class="org.springframework.data.mongodb.core.PersonReadConverter"/>
        </mongo:converter>
        <mongo:converter>
          <bean class="org.springframework.data.mongodb.core.PersonWriteConverter"/>
        </mongo:converter>
      </mongo:custom-converters>
  </mongo:mapping-converter>      

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


</beans>
