I looked at the MongoDB REST Getting started guide from Spring (https://spring.io/guides/gs/accessing-mongodb-data-rest/). When I'm adding an entity in a different package then the Application.java
, say
com.project.rest.core.entities.Account.java
and do the same for the repository
com.project.rest.core.repositories.AccountRepo.java
the Application does not recognize the REST endpoints under localhost:8080 after building with. It just shows
{
"_links": {
"people": {
"href": "http://localhost:8080/people{?page,size,sort}",
"templated": true
},
"profile": {
"href": "http://localhost:8080/profile"
}
}
}
When I put the Account.java
and AccountRepo.java
in the same package where the Application.java
resides, it works.
So, how do I integrate Repositories from different packages in the Application?
Best regards,
Tim
EDIT: My main application class looks as follows:
@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
Even with added @ComponentScan(basePackages="com.project.rest") the AccountRepository is not found by Spring boot.
The repository has the following annotation:
@RepositoryRestResource(collectionResourceRel = "accounts", path="accounts")