From the course: Creating Spring Boot Microservices
Unlock the full course today
Join today to access over 24,400 courses taught by industry experts.
Spring Data MongoDB documents and repositories - Spring Boot Tutorial
From the course: Creating Spring Boot Microservices
Spring Data MongoDB documents and repositories
- [Instructor] Now we're going to create our MongoDB repositories. So I'm going to create a new folder called repo and a new file called image repository dot Java. And this will be an interface. So here's where we apply the spring data MongoDB. This will extend from Mongo repository. And our two options are image, and then the type of the ID is string. Import the image. Did we import the right image? Didn't work. Let's try it again. Import image from model. Very good. Now I'm going to do a source action here so we can see what methods come from spring data MongoDB. We have the find all, the insert, the delete, the save, more find all and more counts by this, using query by example. That's what those examples there are. And finding one by query by example. So those are just some of the default methods we get. And so let's inject, remove that constructor, our image repository, make that lowercase, import that, and generate a constructor. So now we have injected the image repository into…