I have implemented Spring Data Repositories that extents MongoRepository with @RepositoryRestResource
annotation to mark them as REST endpoints. But when the request id is mapped getting the following exception
java.lang.IllegalArgumentException: Couldn't find PersistentEntity for type class io.sample.crm.models.Merchant!
The Repository :
@RepositoryRestResource(collectionResourceRel = "account",path = "account")
public interface MerchantRepository extends MongoRepository<Merchant,String> {
}
The GET request im trying :
http://localhost:9090/crm/account/
The response :
{
"cause": null,
"message": "Couldn't find PersistentEntity for type class io.apptizer.crm.apptizercrmservice.models.Merchant!"
}
Plus I have configured two databases for my each repository.
Application.yml file :
spring:
autoconfigure:
exclude: org.springframework.boot.autoconfigure.mongo.MongoAutoConfiguration
mongodb:
primary:
host: 127.0.0.1
port: 27017
database: db_sample_admin_crm
rest:
base-path: /crm
secondary:
host: 127.0.0.1
port: 27017
database: sample_lead_forms
rest:
base-path: /reports
Main class :
@SpringBootApplication(scanBasePackages = "io.example")
@Configuration
@ComponentScan({"io.example"})
@EntityScan("io.example")
public class App {
public static void main(String[] args) throws Exception {
SpringApplication.run(App.class, args);
InitAuth.initialize();
InitAuth.generateToken();
}
}
What could be gone wrong here?