mongo記錄 { "_id" : ObjectId("5f7066bd96e1084388864d7b"), "orgCd" : "BJ", "name" : "記錄表" } 查詢ObjectId(id)類型的數據 public void findUser(){ Query query = new Query(); Criteria criatira = new Criteria(); criatira.add(Criteria.where("name").is(name)); criatira.add(Criteria.where("_id").is(new ObjectId(userId))); query.addCriteria(criatira); List<User> userList = mongoTemplate.find(query, User.class, "user"); }