Reputation: 151
This is the what I have for the repo:
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRepo extends PagingAndSortingRepository<Person, Long> {
List<Person> findByName(@Param("name") String name);
}
http://localhost:8080/system/people is what I'm trying to access, where "http://localhost:8080/system" is the base url for the spring MVC project
Upvotes: 0
Views: 187
Reputation: 151
I've found the solution for it, according to the http://docs.spring.io/spring-data/rest/docs/2.3.0.RELEASE/reference/html/#getting-started.introduction, I added a class for the data access configuration:
@Configuration
public class CustomizedRestMvcConfiguration extends RepositoryRestMvcConfiguration {
@Override
public RepositoryRestConfiguration config() {
RepositoryRestConfiguration config = super.config();
config.setBasePath("/api");
return config;
}
}
In addition, I have also added @Import(CustomizedRestMvcConfiguration.class)
in my spring applications config class. And now whenever I do a http://localhost:8080/system/api/people call, the database entries can be retrieved.
Upvotes: 1
Reputation: 1009
try
@RequestMapping(value="/people/" , method=RequestMethod.GET)
public interface PersonRepo extends PagingAndSortingRepository<Person, Long> {
List<Person> findByName(@Param("name") String name);
}
Upvotes: 0