Pergunta

I want to create a RESTful server which provides persistency for 2 types of clients: (1) a webpage, so JSON transport is the obvious choice, and (2) a Java stand-alone client. The Java server and Java client should both share the same domain model.

I'm working on getting the server running with Spring Data Rest and JPA. Spring Data Rest looks like a very elegant solution.

However, most of the uses of Spring Data Rest is with a html client or RestTemplates but i have not found any examples of how to de-serialise the JSON back into the same domain objects it originates from.

If there is a better suggestion than Spring Data Rest i would also like to hear.

Foi útil?

Solução 2

i found a nice example of a Spring Data Repository which uses REST as an implementation for the Repository.

see https://github.com/onlyabout/spring-data-rest-client

this allows for using Spring Data in your client application.

Outras dicas

I would recommend jersey,You can very easily write a Java client and also send a JSON response to whatever consumes it. You can check it out here https://jersey.java.net/

I recommend you try the javascript framework "backbone" to code a client of spring data rest in a web application (http://backbonejs.org/). Backbone has a object called "collection" which handles the serialise and deserialise between the Jason documents and the JavaScript objects

Licenciado em: CC-BY-SA com atribuição
Não afiliado a StackOverflow
scroll top