[英]Creating Java POJOs from Mongo collections
我有一個現有的 MongoDB,我需要為所有集合編寫 Java POJO。
是否有任何工具可以從 mongo 集合中自動生成 POJO?
我能夠找到將 Mongo 集合轉換為 JSON 的工具,但找不到將集合轉換為 Java POJO 的合適方法。
使用http://www.jsonschema2pojo.org/
像這樣的 json:
{
"type":"object",
"working":true,
"id":1
}
會產生
-----------------------------------com.example.Example.java-----------------------------------
package com.example;
import com.google.gson.annotations.Expose;
import com.google.gson.annotations.SerializedName;
public class Example {
@SerializedName("type")
@Expose
private String type;
@SerializedName("working")
@Expose
private Boolean working;
@SerializedName("id")
@Expose
private Long id;
public String getType() {
return type;
}
public void setType(String type) {
this.type = type;
}
public Boolean getWorking() {
return working;
}
public void setWorking(Boolean working) {
this.working = working;
}
public Long getId() {
return id;
}
public void setId(Long id) {
this.id = id;
}
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.