My setup works on my local but not when I deploy it to CloudFoundry/mongolab.
The config is very similar to the docs.
My local spring config
This is usually caused if the Mongo mapping metadata obtained for entities does not scan entities at application startup. By default, AbstractMongoConfiguration
uses the package of the actual configuration class to look for @Document
annotated classes at startup.
The exception message makes me assume that SpringCloudMongoDBConfiguration
is not located in any of the super packages of com.foo.model.project
. There are two solutions to this:
MongoConfiguration.getMappingBasePackage()
.The reason you might see the configuration working in the local environment is that the mapping metadata might be obtained through a non-persisting persistence operation (e.g. a query) and everything else proceeding from there.