Note
|
This snapshot copy is captured from SpringOne 2GX 2015 in Washingon, D.C. |
Spring-a-Gram is a demonstration of the Spring stack used to upload and view pictures.
Spring Data REST makes it incredibly simple to define and export data store entities. What does this mean? You declare the POJOs that are stored in your database. In this case, we are using a JPA, in-memory data store. (Spring Data REST supports other data stores as well). You then define a related repository interface. Spring Data REST takes it from there to create a hypermedia-driven, RESTful interface using Spring MVC that lets you create, read, update, and delete data.
This sample application demonstrations how declaring a backend aimed at storing image data can make it as simple as possible to upload pictures and then turn around and display them on a website. This opens the door to other front ends, like an iOS or Android app.
If you want to run it right now, you need:
-
Java 8+
-
Maven 3.0+ (http://maven.apache.org)
-
Bower 1.3+ (http://bower.io)
To download and run:
-
git clone git@github.com:gregturn/spring-a-gram.git
to grab a local copy (or clone your own fork). -
bower install
to pull down javascript libraries. If you get prompted about jQuery, accept the version specified in bower.json -
mvn clean spring-boot:run
Note
|
To deploy a copy to PWS, you need a Java 8 build pack. Execute cf push spring-a-gram -p target/spring-a-gram-0.1.0.jar -b https://github.com/spring-io/java-buildpack.git and you’ll be set.
|
This should get the app started courtesy of Spring Boot. Now you can traverse the app from different view points.
-
From the command line, interrogate the API with
curl localhost:8080/api
. Navigate to the other links. -
From the desktop, visit http://localhost:8080 to see the Desktop version of the web experience.
-
From a mobile device, visit http://localhost:8080 and see a different flow, optimized for the smaller real estate.