我想在mongodb中插入如下所示的Bean,我使用springboot 2.0.4.RELEASE,我希望一个字段具有默认值,例如100.00,该怎么做?
public class Bean{
String uid;
double a;
}
答案 0 :(得分:0)
您必须注释您的Bean,最好在您的收藏夹中包含ID
import org.springframework.data.annotation.Id;
import org.springframework.data.mongodb.core.mapping.Document;
@Document(collection = "your_collection_name")
public class Bean {
@Id
private String id;
private String uid;
private double a = 100.00;
//getter and setter methods
}