|
| 1 | += Spring Data REST image:https://img.shields.io/badge/Revved%20up%20by-Develocity-06A0CE?logo=Gradle&labelColor=02303A["Revved up by Develocity", link="https://ge.spring.io/scans?search.rootProjectNames=Spring Data REST"] |
| 2 | + |
| 3 | +The goal of the project is to provide a flexible and configurable mechanism for writing simple services that can be exposed over HTTP. |
| 4 | + |
| 5 | +This takes your Spring Data repositories and front-ends them with HTTP, allowing you full CRUD capability over your entities, to include managing associations. |
| 6 | + |
| 7 | +== Features |
| 8 | + |
| 9 | +* Exposes a discoverable REST API for your domain model using HAL as media type. |
| 10 | +* Exposes https://docs.spring.io/spring-data/rest/docs/current/reference/html/#repository-resources[collection, item and association resources] representing your model. |
| 11 | +* Supports pagination via https://docs.spring.io/spring-data/rest/docs/current/reference/html/#paging-and-sorting[navigational links]. |
| 12 | +* Allows to dynamically filter collection resources. |
| 13 | +* Exposes dedicated https://docs.spring.io/spring-data/rest/docs/current/reference/html/#repository-resources.query-method-resource[search resources for query methods] defined in your repositories. |
| 14 | +* Allows to https://docs.spring.io/spring-data/rest/docs/current/reference/html/#events[hook into the handling of REST requests] by handling Spring `ApplicationEvents`. |
| 15 | +* https://docs.spring.io/spring-data/rest/docs/current/reference/html/#metadata[Exposes metadata] about the model discovered as ALPS and JSON Schema. |
| 16 | +* Allows to define client specific representations through https://docs.spring.io/spring-data/rest/docs/current/reference/html/#projections-excerpts[projections]. |
| 17 | +* Ships the latest release of https://docs.spring.io/spring-data/rest/docs/current/reference/html/#tools.hal-explorer[HAL Explorer] to easily explore HAL and HAL-FORMS based HTTP responses. |
| 18 | +* Supports JPA, MongoDB, Neo4j, Solr, Cassandra, Gemfire. |
| 19 | +* Allows https://docs.spring.io/spring-data/rest/docs/current/reference/html/#customizing-sdr[advanced customizations] of the default resources exposed. |
| 20 | + |
| 21 | +include::https://raw.githubusercontent.com/spring-projects/spring-data-build/refs/heads/main/etc/readme/code-of-conduct.adoc[] |
| 22 | + |
| 23 | +== Getting Started |
| 24 | + |
| 25 | +Here is a quick teaser of an application using Spring Data REST in Java: |
| 26 | + |
| 27 | +[source,java] |
| 28 | +---- |
| 29 | +@CrossOrigin |
| 30 | +@RepositoryRestResource(path = "people") |
| 31 | +public interface PersonRepository extends CrudRepository<Person, Long> { |
| 32 | +
|
| 33 | + List<Person> findByLastname(String lastname); |
| 34 | +
|
| 35 | + @RestResource(path = "byFirstname") |
| 36 | + List<Person> findByFirstnameLike(String firstname); |
| 37 | +} |
| 38 | +
|
| 39 | +@Configuration |
| 40 | +@EnableMongoRepositories |
| 41 | +class ApplicationConfig extends AbstractMongoConfiguration { |
| 42 | +
|
| 43 | + @Override |
| 44 | + public MongoClient mongoClient() { |
| 45 | + return new MongoClient(); |
| 46 | + } |
| 47 | +
|
| 48 | + @Override |
| 49 | + protected String getDatabaseName() { |
| 50 | + return "springdata"; |
| 51 | + } |
| 52 | +} |
| 53 | +---- |
| 54 | + |
| 55 | +[source,bash] |
| 56 | +---- |
| 57 | +curl -v "http://localhost:8080/people/search/byFirstname?firstname=Oliver*&sort=name,desc" |
| 58 | +---- |
| 59 | + |
| 60 | +include::https://raw.githubusercontent.com/spring-projects/spring-data-build/refs/heads/main/etc/readme/dependencies.adoc[] |
| 61 | + |
| 62 | +include::https://raw.githubusercontent.com/spring-projects/spring-data-build/refs/heads/main/etc/readme/upgrading-getting-help-reporting-issues.adoc[] |
| 63 | + |
| 64 | +== Guides |
| 65 | + |
| 66 | +The https://spring.io/[spring.io] site contains several guides that show how to use Spring Data step-by-step: |
| 67 | + |
| 68 | +* https://spring.io/guides/gs/accessing-data-rest/[Accessing JPA Data with REST] is a guide to creating a REST web service exposing data stored with JPA through repositories. |
| 69 | +* https://spring.io/guides/gs/accessing-mongodb-data-rest/[Accessing MongoDB Data with REST] is a guide to creating a REST web service exposing data stored in MongoDB through repositories. |
| 70 | +* https://spring.io/guides/gs/accessing-neo4j-data-rest/[Accessing Neo4j Data with REST] is a guide to creating a REST web service exposing data stored in Neo4j through repositories. |
| 71 | +* https://spring.io/guides/gs/accessing-gemfire-data-rest/[Accessing GemFire Data with REST] is a guide to creating a REST web service exposing data stored in Pivotal GemFire through repositories. |
| 72 | + |
| 73 | +== Examples |
| 74 | + |
| 75 | +* https://github.com/spring-projects/spring-data-examples/[Spring Data Examples] contains example projects that explain specific features in more detail. |
| 76 | + |
| 77 | +:antora-output: spring-data-rest-distribution/target/site/index.html |
| 78 | + |
| 79 | +include::https://raw.githubusercontent.com/spring-projects/spring-data-build/refs/heads/main/etc/readme/building.adoc[] |
| 80 | + |
| 81 | +include::https://raw.githubusercontent.com/spring-projects/spring-data-build/refs/heads/main/etc/readme/license.adoc[] |
0 commit comments