I'm using spring-boot-starter-data-rest and spring-boot-starter-data-mongodb as per the tutorial given here. I'm attempting to create a custom method for a MongoRepository, but having no success.
I've followed the steps given for adding custom behavior to single repositories, but I'm getting a 404 error when I attempt to access the custom method. Hitting the parent endpoint also shows no sign of the method, but I didn't expect it to do that.
Help me, please! What am I doing wrong!?
My code is as follows:
Application.java
@SpringBootApplication
public class Application extends AbstractMongoConfiguration {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
ItemRepositoryCustom.java
public interface ItemRepositoryCustom {
void customMethod();
}
ItemRepositoryImpl.java
public class ItemRepositoryImpl {
@Override
public void customMethod() {
...
}
}
ItemRepository.java
@RepositoryRestResource(collectionResourceRel="items", path="items")
public interface ItemRepository extends MongoRepository<Item, String>, ItemRepositoryCustom {
List<Item> findByName(@Param("name") String name);
}