Skip to content

Instantly share code, notes, and snippets.

@AndyBowes
Created July 4, 2012 13:43
Show Gist options
  • Save AndyBowes/3047403 to your computer and use it in GitHub Desktop.
Save AndyBowes/3047403 to your computer and use it in GitHub Desktop.
Mongo Spring Application Context
<?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:mongo="http://www.springframework.org/schema/data/mongo"
xsi:schemaLocation="http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.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/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
<!-- Default bean name is 'mongo' -->
<mongo:mongo host="localhost" port="27017" />
<bean id="mongoTemplate" class="org.springframework.data.mongodb.core.MongoTemplate">
<constructor-arg ref="mongo" />
<constructor-arg name="databaseName" value="testAlbums" />
</bean>
<context:component-scan base-package="uk.co.jfactory.database.music" />
<!-- To translate any MongoExceptions thrown in @Repository annotated classes -->
<context:annotation-config />
<!-- Create instances of Mongo Repositories -->
<mongo:repositories base-package="uk.co.jfactory.database.music.dao.repository" mongo-template-ref="mongoTemplate" />
</beans>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment