https://github.com/gregturn/spring-data-rest-sample
Spring Boot CLI app with Spring Data REST
https://github.com/gregturn/spring-data-rest-sample
Last synced: 9 months ago
JSON representation
Spring Boot CLI app with Spring Data REST
- Host: GitHub
- URL: https://github.com/gregturn/spring-data-rest-sample
- Owner: gregturn
- Created: 2015-02-20T21:59:13.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2015-02-24T16:19:59.000Z (over 11 years ago)
- Last Synced: 2025-08-23T22:59:57.396Z (9 months ago)
- Language: Java
- Size: 141 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
Awesome Lists containing this project
README
== How to run
You can choose to the Spring Boot CLi version of this sample:
. Install Spring Boot CLI
. spring jar app.jar sample.groovy && java -jar app.jar
. In another shell, use curl to interrogate the service
Or you can check out the Spring Boot Java-based version:
. mvn clean spring-boot:run
Either of these options will let you poke around with a simple example of Spring Data REST.
== What you'll see
----
$ curl localhost:8080/persons
----
It will yield:
[source,javascript]
----
{
"_embedded" : {
"persons" : [ {
"firstName" : "Frodo",
"lastName" : "Baggins",
"addresses" : [ {
"street" : "Bag End",
"state" : "The Shire",
"country" : "Middle Earth"
}, {
"street" : "The Undying Lands",
"state" : "Ships",
"country" : "Elven Lands"
} ],
"_links" : {
"self" : {
"href" : "http://localhost:8080/persons/1{?projection}",
"templated" : true
},
"addresses" : {
"href" : "http://localhost:8080/persons/1/addresses"
}
}
} ]
}
}
----
This shows an excerpt projection being applied. It causes the address resources to get inlined. You can still navigate to that collection.
----
$ curl localhost:8080/persons/1/addresses
----
This will show links for each address:
[source,javascript]
----
{
"_embedded" : {
"addresses" : [ {
"street" : "Bag End",
"state" : "The Shire",
"country" : "Middle Earth",
"_links" : {
"self" : {
"href" : "http://localhost:8080/addresses/1"
}
}
}, {
"street" : "The Undying Lands",
"state" : "Ships",
"country" : "Elven Lands",
"_links" : {
"self" : {
"href" : "http://localhost:8080/addresses/2"
}
}
} ]
}
}
----