I want insert a Bean like below into mongodb,I use springboot 2.0.4.RELEASE,I want the a field have a default value such as 100.00,how to do it?
public class Bean{
String uid;
double a;
}
I want insert a Bean like below into mongodb,I use springboot 2.0.4.RELEASE,I want the a field have a default value such as 100.00,how to do it?
public class Bean{
String uid;
double a;
}
you must annotate your Bean, it is preferred to have id in your collection
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
}