user2580016
user2580016

Reputation: 151

Getting "No mapping found for HTTP request with URI [/system/people]..." when try to access jpa data via rest

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

Answers (2)

user2580016
user2580016

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

Alaa Abuzaghleh
Alaa Abuzaghleh

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

Related Questions