springboot2.X 使用spring-data组件对MongoDB做CURD
使用背景
基于快速开发,需求不稳定的情况, 我决定使用MongoDB作为存储数据库,搭配使用spring-data...因为快速开发,使用spring data可以直接在类上建表等其他操作,而且对于复合数据模型,MongoDB可以直接存储
代码地址
gitee
github
入门普通级别
1.引入maven依赖
Mongo的实体类
@Document(collection=“female”)
设置id: @Id
设置属性
构建索引
getter/setter
Female.java...因为我的springboot项目已经引入了slf4j,没必要重复声明,自己可以通过idea的maven dependence查看是否有引入,没有则需要重新引入
2.使用dsl
在dao的repository...中继承QuerydslPredicateExecutor
public interface FemaleRepository extends MongoRepository<Female,String