I'm developing a component based CRUD application using Spring Data JPA and Spring Data REST. I have several components. For example system component has the User
model and the UserRepository
. Components are differenciated by the package names. like com.example.app.<component_name>
So to make my REST API look cleaner, I need to implement the API URL as below.
host:8080/<component_name>/<model_collection_name>
for example
host:8080/system/users
I did the following in my repository
@RepositoryRestResource(collectionResourceRel = "users", path = "system/users")
public interface UserRepository extends PagingAndSortingRepository<User, Long> {
...
}
this generates the following, when I goto http://localhost:8080
{
"_links": {
"users": {
"href": "http://localhost:8080/system/users{?page,size,sort}",
"templated": true
},
...
But when I goto http://localhost:8080/system/users
It gives an error
Fri May 22 17:56:37 IST 2015 There was an unexpected error (type=Not Found, status=404). No message available
NOTE : If I mapped the path to system-users
then it works fine, but when I use a /
in the path such as system/users
, it breaks and gives the error.