Matt Raible
The @RepositoryRestResource
annotation creates endpoints for the Car
entity at http://localhost:8080/cars
.
package com.okta.developer.demo;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
@RepositoryRestResource
interface CarRepository extends JpaRepository<Car, Long> {
}
You can GET, PUT, POST, and DELETE to it. For example, here’s how with HTTPie.
http GET :8080/cars
http POST :8080/cars name='VW Bus’
http PUT :8080/cars/6 email='VW Bug’
http DELETE :8080/cars/6