What is the correct way to close a mongo connection using spring-mongo?

I am using spring-mongo in my webapp. When I uninstall my application in Tomcat7, a memory leak occurs. I suspect that this may be a Mongo object, which I obviously did not close. I would like to know what is the correct way (and location) to close it.

+1
source share
1 answer

How about something like this:

@Component public class MongoDBManager { @Autowired Mongo mongo; @PreDestroy public void shutdown() { mongo.close(); } } 
+1
source

All Articles