问题
Is there any Spring Annotation to Set Default value for a Field (Mongo) ?
回答1:
No need for spring annotations, this should do the trick:
import org.springframework.data.mongodb.core.mapping.Document;
import org.springframework.data.mongodb.core.mapping.Field;
@Document
public class Doc {
@Field
private String field = "CustomDefaultValue";
}
来源:https://stackoverflow.com/questions/41344173/is-there-any-spring-annotation-to-set-default-value-for-a-field-mongo