Is there any Spring Annotation to Set Default value for a Field (Mongo)?

牧云@^-^@ 提交于 2020-01-14 09:49:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!