Skip to content

Instantly share code, notes, and snippets.

@gabfssilva
Created November 16, 2017 12:16
Show Gist options
  • Save gabfssilva/a3e22761bffde731dcbba5a5a51b165a to your computer and use it in GitHub Desktop.
Save gabfssilva/a3e22761bffde731dcbba5a5a51b165a to your computer and use it in GitHub Desktop.
spring data rest
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.data.rest.core.annotation.RepositoryRestResource;
import javax.persistence.Entity;
import javax.persistence.Table;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.SpringApplication;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
@Entity
public class Person {
@Id @GeneratedValue @Column Long id;
@Column String name;
@Column Int age;
@Column String occupation;
}
@RepositoryRestResource(collectionResourceRel = "people", path = "people")
public interface PersonRestRepository extends PagingAndSortingRepository<Person, Long> {}
public class Main {
public static void main(String args []) { SpringApplication.run(Application.class, args); }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment