Using MongoTemplate, I have saved a json in a collection. The objectid is generated automatically by MongoDB, I suppose.
How to get the objectid at the instant while saving?
mongotemplate.save(data,"collection");
如果我理解你正确你可以这样做,如果对象“数据”有字段“id”
mongotemplate.save(data,"collection").getId();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.