I'm using Spring Boot (v1.3.1) with Spring Data Mongo (1.8.2) and trying to add an aggregation to one of our existing Mongo repositories, but I'm having some trouble getting it all working together.
I'm referencing the Spring documentation related to adding custom behavior to a single repository.
On the application config we have the following :
@EnableMongoRepositories(basePackages = { "com.test" }, repositoryImplementationPostfix = "Impl")
To illustrate this I put together some test classes. My custom interface looks like this :
public interface TestRepositoryCustom {
TestEntity getStuff();}
My repository looks like this:
public interface TestRepository extends MongoRepository<TestEntity, String>, TestRepositoryCustom {
TestEntity findByName(@Param("name") String name);}
The implementing class is here :
public class TestRepositoryImpl implements TestRepositoryCustom {
@Override
public TestEntity getStuff(){
System.out.println("!!!!TESTOK!!!");
return new TestEntity();
}}
The getStuff method is not available when I look at the search URL ( http://localhost:9090/testEntities/search/ ). Also when I go to the URL ( http://localhost:9090/testEntities/search/getStuff ) I'm getting a 404.
Out of desperation I've tried changing the repositoryImplementationPostfix and have noticed that if implementing class suffix and this value are not in sync I get an error like this:
...
Caused by: org.springframework.data.mapping.PropertyReferenceException: No property getStuff found for type TestEntity!
...
So it seems like the app context is aware of the implementing class, but I just can't figure out what I'm doing wrong.
Any input would be appreciated