Hi,
I'm using version 3.1.2.RELEASE of Spring.
I would like to be able to specify the template bean that backs my repository bean, using the Spring MongoDB data library.
http://michaelbarnesjr.wordpress.com...ng-data-mongo/ seems to suggest that you may have a mongo-template-ref parameter as an attribute of a repository element (nested inside of a repositories element) in the application context xml. However, when I try this, I get an exception when trying to instantiate the bean saying that the "mongoTemplate" bean cannot be found-- even though I actually specified a different MongoTemplate bean to use.
In case it is relevant, my MongoTemplate bean is specified in terms of a FactoryBean.
I notice that if I have the mongo-template-ref attribute in the repositories element instead, then things seem to work, but this won't be as convenient when I have more than one repository.
My MongoTemplate bean is specified as:
My repositories element, with the mongo-template-ref attribute on the repository element is:Code:<bean id="jobMongoTemplate" class="[...].MongoOperationsFactoryBean"> <constructor-arg name="mongoManager" ref="developmentMongoManager" /> <constructor-arg name="dbName" value="Jobs" /> </bean>
JobRepository is the only interface that exists in the specified repositories package.Code:<mongo:repositories base-package="[...].repositories"> <mongo:repository id="jobRepository" mongo-template-ref="mongoTemplate"/> </mongo:repositories>
Can the mongo-template-ref attribute in fact be used in the repository element... or does it only work in the repositories element? Is there a possible complication from using a FactoryBean to produce the MongoTemplate bean?
Thank you.


Reply With Quote
