第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問(wèn)題,去搜搜看,總會(huì)有你想問(wèn)的

使用java將數(shù)據(jù)插入mongodb

使用java將數(shù)據(jù)插入mongodb

qq_笑_17 2023-05-24 15:04:00
我正在嘗試使用 java 將數(shù)據(jù)插入 MongoDB,但在嘗試編譯代碼時(shí)出現(xiàn)錯(cuò)誤。我不知道是什么導(dǎo)致了錯(cuò)誤。我想添加新書(shū)條目。error message: required: String,Object  found: List<Document>  reason: actual and formal argument lists differ in lengthUseMongoDB.java:61: error: method put in class Document cannot be applied to given types;book.put(publishers);private MongoCollection<Document> books = db.getCollection("books");  void insertanewbook() {            Document book = new Document();    book.put("title", "test");          book.put("category","test");                book.put("price",12.3);                List<Document> authors = new ArrayList<Document>();    Document author = new Document();                author.put("first_name","jonn");                author.put("last_name","james");                author.put("country","t");                author.put("website","www.test.com");    authors.add(author);    book.put(authors);    List<Document> publishers = new ArrayList<Document>();    Document publisher = new Document();                publisher.put("publish_date",new Date());                publisher.put("name","test");                publisher.put("country","test");    publisher.put("website","www.test.com");    publishers.add(publisher);    book.put(publishers);                    books.insertOne(book);  }
查看完整描述

1 回答

?
搖曳的薔薇

TA貢獻(xiàn)1793條經(jīng)驗(yàn) 獲得超6個(gè)贊

從您發(fā)布的錯(cuò)誤消息...

reason:?actual?and?formal?argument?lists?differ?in?length

換句話說(shuō),方法put需要兩個(gè)參數(shù),而您只提供一個(gè)。從您發(fā)布的代碼中,您缺少對(duì)方法調(diào)用的關(guān)鍵put()。只需添加相關(guān)密鑰,例如

book.put("publishers",?publishers);


查看完整回答
反對(duì) 回復(fù) 2023-05-24
  • 1 回答
  • 0 關(guān)注
  • 172 瀏覽
慕課專(zhuān)欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢(xún)優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)