@Autowired
private MongoTemplate template;
public void dropAll() {
//获取所有的表
for (String table : template.getDb().getCollectionNames()) {
//系统文件不能删除
if (!table.startsWith("system"))
template.getDb().getCollection(table).drop();
}
}
使用spring MongoTemplate 删除MongoDB的表
最新推荐文章于 2024-05-31 10:22:26 发布