时间:2021-07-01 10:21:17 帮助过:48人阅读
二.在application.properties中配置MongoDB配置
spring.data.mongodb.uri=mongodb://root:root@localhost:27017/test
三.声明entity和repository
@Document(collection = "t_app") @Data public class App { @Id private ObjectId id; @Field("api_key") private String apiKey; private String appname; private List<Object> activities; }
@Repository public interface AppRepository extends MongoRepository<App, ObjectId> { App findOneByApiKey(String apiKey); }
四.支持的Repository
ps:KeyWord可以用and方法连起来。
如:
List<DiscountCode> findFirst5ByActivityIdInAndEndTimeAfterAndStatus(List<ObjectId> activityIds, Date endTime,String status);
五.Repository声明和使用
@Autowired private AppRepository appRepository;
Spring Boot MongoDB 简化开发
标签:操作 ext extends pat inline ace images disco ring