org.springframework.data.mapping.MappingException: Couldn‘t find PersistentEntity for type class org

org.springframework.data.mapping.MappingException: Couldn’t find PersistentEntity for type class org.bson.Document!
没有设置 col name

 @PostMapping("/updateMongo")
    public Object updateMongo(@RequestBody  MongoReq mongoReq) {

        Map<String, Object> updateMap = mongoReq.getUpdateMap();
//        updateMap.get("")
        String id =(String) updateMap.get("id");
        Query query = Query.query(Criteria.where("_id").is(
                new ObjectId(id)
        ));

        Update update = new Update();
        for (Map.Entry<String, Object> stringObjectEntry : updateMap.entrySet()) {
            String key = stringObjectEntry.getKey();
            update.set(key, stringObjectEntry.getValue());
        }
        UpdateResult updateResult = mongoTemplate.updateFirst(query, update, Document.class,mongoReq.getCollectionName());
        return  updateResult;

//        mongoTemplate.updateFirst(query, update, YourEntity.class);
    }

版权声明:本文为jonathan_joestar原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。