{"id":16394,"date":"2013-08-16T10:00:37","date_gmt":"2013-08-16T07:00:37","guid":{"rendered":"http:\/\/www.javacodegeeks.com\/?p=16394"},"modified":"2013-08-14T19:00:41","modified_gmt":"2013-08-14T16:00:41","slug":"spring-data-rest-in-action","status":"publish","type":"post","link":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html","title":{"rendered":"Spring Data REST in Action"},"content":{"rendered":"<h3>What is spring-data-rest?<\/h3>\n<p><a href=\"http:\/\/www.springsource.org\/spring-data\/rest\">spring-data-rest<\/a>, a recent addition to the <a href=\"http:\/\/www.springsource.org\/spring-data\">spring-data<\/a> project, is a framework that helps you expose your entities directly as RESTful webservice endpoints. Unlike rails, grails or roo it does not generate any code achieving this goal. spring data-rest supports JPA, MongoDB, JSR-303 validation, <a href=\"http:\/\/stateless.co\/hal_specification.html\">HAL<\/a> and many more. It is really innovative and lets you setup your RESTful webservice within minutes. In this example i&#8217;ll give you a short overview of what spring-data-rest is capable of.<\/p>\n<h3>Initial Configuration<\/h3>\n<p>I&#8217;m gonna use the new Servlet 3 Java Web Configuration instead of an ancient web.xml. Nothing really special here.<\/p>\n<pre class=\" brush:java\">public class WebAppInitializer extends AbstractAnnotationConfigDispatcherServletInitializer {\r\n\r\n    @Override\r\n    protected Class&lt;?&gt;[] getRootConfigClasses() {\r\n        return new Class&lt;?&gt;[]{AppConfiguration.class};\r\n    }\r\n\r\n    @Override\r\n    protected Class&lt;?&gt;[] getServletConfigClasses() {\r\n        return new Class[]{WebConfiguration.class};\r\n    }\r\n\r\n    @Override\r\n    protected String[] getServletMappings() {\r\n        return new String[]{\"\/\"};\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/WebAppInitializer.java\">WebAppInitializer.java on github<\/a><\/p>\n<p>I am initializing hibernate as my database abstraction layer in the <i>AppConfiguration<\/i> class. I&#8217;m using an embedded database (<a href=\"http:\/\/hsqldb.org\/\">hsql<\/a>), since i want to keep this showcase simple stupid. Still, nothing special here.<\/p>\n<pre class=\" brush:java\">@Configuration\r\n@EnableJpaRepositories\r\n@EnableTransactionManagement\r\npublic class AppConfiguration {\r\n\r\n    @Bean\r\n    public DataSource dataSource() {\r\n        EmbeddedDatabaseBuilder builder = new EmbeddedDatabaseBuilder();\r\n        return builder.setType(EmbeddedDatabaseType.HSQL).build();\r\n    }\r\n\r\n    @Bean\r\n    public LocalContainerEntityManagerFactoryBean entityManagerFactory() {\r\n        HibernateJpaVendorAdapter vendorAdapter = new HibernateJpaVendorAdapter();\r\n        vendorAdapter.setDatabase(Database.HSQL);\r\n        vendorAdapter.setGenerateDdl(true);\r\n\r\n        LocalContainerEntityManagerFactoryBean factory = new LocalContainerEntityManagerFactoryBean();\r\n        factory.setJpaVendorAdapter(vendorAdapter);\r\n        factory.setPackagesToScan(getClass().getPackage().getName());\r\n        factory.setDataSource(dataSource());\r\n\r\n        return factory;\r\n    }\r\n\r\n    @Bean\r\n    public PlatformTransactionManager transactionManager() {\r\n        return new JpaTransactionManager();\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/AppConfiguration.java\">AppConfiguration.java on github<\/a><\/p>\n<p>Now to the application servlet configuration: <i>WebConfiguration<\/i><\/p>\n<pre class=\" brush:java\">@Configuration\r\npublic class WebConfiguration extends RepositoryRestMvcConfiguration {\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/WebConfiguration.java\">WebConfiguration.java on github<\/a><\/p>\n<p>Oh, well thats a bit short isnt it? Not a single line of code required for a complete setup. This is a really nice application of the <a href=\"http:\/\/en.wikipedia.org\/wiki\/Convention_over_configuration\">convention over configuration<\/a> paradigm. We can now start creating spring-data-jpa repositories as they will be exposed as RESTful resources automatically. And we can still add custom configuration to the <i>WebConfiguration<\/i> class if needed.<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<p>The Initialization was really short and easy. We didn&#8217;t have to code anything special. The only thing we did was setting up a database connection and hibernate, which is obviously inevitable. Now, that we have setup our &#8220;REST Servlet&#8221; and persistence, lets move on to the application itself, starting with the model.<\/p>\n<h3>The Model<\/h3>\n<p>I&#8217;ll keep it really simple creating only two related entities.<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/bookapi_model.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/bookapi_model.png\" alt=\"bookapi_model\" width=\"296\" height=\"122\" class=\"aligncenter size-full wp-image-16428\" \/><\/a><\/p>\n<pre class=\" brush:java\">@Entity\r\npublic class Book {\r\n\r\n    @Id\r\n    private String isbn;\r\n\r\n    private String title;\r\n\r\n    private String language;\r\n\r\n    @ManyToMany\r\n    private List&lt;Author&gt; authors;\r\n\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/model\/Book.java\">Book.java on github<\/a><\/p>\n<pre class=\" brush:java\">@Entity\r\npublic class Author {\r\n\r\n    @Id\r\n    @GeneratedValue(strategy = GenerationType.SEQUENCE)\r\n    private Integer id;\r\n\r\n    private String name;\r\n\r\n    @ManyToMany(mappedBy = \"authors\")\r\n    private List&lt;Book&gt; books;\r\n\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/model\/Author.java\">Author.java on github<\/a><\/p>\n<p>To finally make the entities persistent and exposed as a RESTful webservice, we need spring-data repositories. A repository is basically a <a href=\"http:\/\/en.wikipedia.org\/wiki\/Data_access_object\">DAO<\/a>. It offers <a href=\"http:\/\/en.wikipedia.org\/wiki\/Create,_read,_update_and_delete\">CRUD<\/a> functionality for our entities. spring-data takes away most of your programming effort creating such repositories. We just have to define an empty interface, spring-data does everything else out of the box. Still, it is easily customizable thanks to its design by convention over configuration!<\/p>\n<h3>The Actual Repositories<\/h3>\n<pre class=\" brush:java\">@RestResource(path = \"books\", rel = \"books\")\r\npublic interface BookRepository extends PagingAndSortingRepository&lt;Book, Long&gt; {\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/BookRepository.java\">BookRepository.java on github<\/a><\/p>\n<pre class=\" brush:java\">@RestResource(path = \"authors\", rel = \"authors\")\r\npublic interface AuthorRepository extends PagingAndSortingRepository&lt;Author, Integer&gt; {\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/main\/java\/com\/blogspot\/babdev\/bookapi\/AuthorRepository.java\">AuthorRepository.java on github<\/a><\/p>\n<p>Again, there is nearly no code needed. Even the <i>@RestResource<\/i> annotation could be left out. But if i did, the path and rel would be named after the entity, which i dont want. A REST resource that contains multiple children should be named plural though.<\/p>\n<h3>Accessing The Result<\/h3>\n<p>Our RESTful webservice is now ready for deployment. Once run, it lists all available resources on the root, so you can navigate from there.<\/p>\n<p><b><i>GET http:\/\/localhost:8080\/<\/i><\/b><\/p>\n<pre class=\" brush:java\">{\r\n  \"links\" : [ {\r\n    \"rel\" : \"books\",\r\n    \"href\" : \"http:\/\/localhost:8080\/books\"\r\n  }, {\r\n    \"rel\" : \"authors\",\r\n    \"href\" : \"http:\/\/localhost:8080\/authors\"\r\n  } ],\r\n  \"content\" : [ ]\r\n}<\/pre>\n<p>Fine! Now lets create an author and a book.<\/p>\n<p><b><i>POST http:\/\/localhost:8080\/authors<\/i><\/b><\/p>\n<pre class=\" brush:java\">{\"name\":\"Uncle Bob\"}<\/pre>\n<p><b>Response<\/b><\/p>\n<pre class=\" brush:java\">201 Created\r\nLocation: http:\/\/localhost:8080\/authors\/1<\/pre>\n<p><b><i>PUT http:\/\/localhost:8080\/books\/0132350882<\/i><\/b><\/p>\n<pre class=\" brush:java\">{\r\n  \"title\": \"Clean Code\",\r\n  \"authors\": [\r\n      {\r\n          \"rel\": \"authors\",\r\n          \"href\": \"http:\/\/localhost:8080\/authors\/1\"\r\n      }\r\n  ]\r\n}<\/pre>\n<p><b>Response<\/b><\/p>\n<pre class=\" brush:java\">201 Created<\/pre>\n<p>Noticed how i used PUT to create the book? This is because its id is the actual isbn. I have to tell the server which isbn to use since he cant guess it. I used POST for the author as his id is just an incremental number that is generated automatically. Also, i used a link to connect both, the book (<i>\/books\/0132350882<\/i>) and the author (<i>\/authors\/1<\/i>). This is basically what hypermedia is all about: Links are used for navigation and relations between entities.<\/p>\n<p>Now, lets see if the book was created accordingly.<\/p>\n<p><b><i>GET http:\/\/localhost:8080\/books<\/i><\/b><\/p>\n<pre class=\" brush:java\">{\r\n  \"links\" : [ ],\r\n  \"content\" : [ {\r\n    \"links\" : [ {\r\n      \"rel\" : \"books.Book.authors\",\r\n      \"href\" : \"http:\/\/localhost:8080\/books\/0132350882\/authors\"\r\n    }, {\r\n      \"rel\" : \"self\",\r\n      \"href\" : \"http:\/\/localhost:8080\/books\/0132350882\"\r\n    } ],\r\n    \"title\" : \"Clean Code\"\r\n  } ],\r\n  \"page\" : {\r\n    \"size\" : 20,\r\n    \"totalElements\" : 1,\r\n    \"totalPages\" : 1,\r\n    \"number\" : 1\r\n  }\r\n}<\/pre>\n<p>Fine!<\/p>\n<p>Here is an Integration Test, following these steps automatically. It is also available in the example on github.<\/p>\n<pre class=\" brush:java\">public class BookApiIT {\r\n\r\n    private final RestTemplate restTemplate = new RestTemplate();\r\n\r\n    private final String authorsUrl = \"http:\/\/localhost:8080\/authors\";\r\n    private final String booksUrl = \"http:\/\/localhost:8080\/books\";\r\n\r\n    @Test\r\n    public void testCreateBookWithAuthor() throws Exception {\r\n        final URI authorUri = restTemplate.postForLocation(authorsUrl, sampleAuthor()); \/\/ create Author\r\n\r\n        final URI bookUri = new URI(booksUrl + \"\/\" + sampleBookIsbn);\r\n        restTemplate.put(bookUri, sampleBook(authorUri.toString())); \/\/ create Book linked to Author\r\n\r\n        Resource&lt;Book&gt; book = getBook(bookUri);\r\n        assertNotNull(book);\r\n\r\n        final URI authorsOfBookUri = new URI(book.getLink(\"books.Book.authors\").getHref());\r\n        Resource&lt;List&lt;Resource&lt;Author&gt;&gt;&gt; authors = getAuthors(authorsOfBookUri);\r\n        assertNotNull(authors.getContent());\r\n        assertFalse(authors.getContent().isEmpty()); \/\/ check if \/books\/0132350882\/authors contains an author\r\n    }\r\n\r\n    private String sampleAuthor() {\r\n        return \"{\\\"name\\\":\\\"Robert C. Martin\\\"}\";\r\n    }\r\n\r\n    private final String sampleBookIsbn = \"0132350882\";\r\n\r\n    private String sampleBook(String authorUrl) {\r\n        return \"{\\\"title\\\":\\\"Clean Code\\\",\\\"authors\\\":[{\\\"rel\\\":\\\"authors\\\",\\\"href\\\":\\\"\" + authorUrl + \"\\\"}]}\";\r\n    }\r\n\r\n    private Resource&lt;Book&gt; getBook(URI uri) {\r\n        return restTemplate.exchange(uri, HttpMethod.GET, null, new ParameterizedTypeReference&lt;Resource&lt;Book&gt;&gt;() {\r\n        }).getBody();\r\n    }\r\n\r\n    private Resource&lt;List&lt;Resource&lt;Author&gt;&gt;&gt; getAuthors(URI uri) {\r\n        return restTemplate.exchange(uri, HttpMethod.GET, null, new ParameterizedTypeReference&lt;Resource&lt;List&lt;Resource&lt;Author&gt;&gt;&gt;&gt;() {\r\n        }).getBody();\r\n    }\r\n}<\/pre>\n<p><a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/blob\/master\/spring-data-rest\/src\/test\/java\/com\/blogspot\/babdev\/bookapi\/BookApiIT.java\">BookApiIT.java on github <\/a><\/p>\n<h3>Conclusion<\/h3>\n<p>We have created a complete RESTful webservice without much coding effort. We just defined our entities and database connection. spring-data-rest stated that everything else is just boilerplate, and i agree.<\/p>\n<p>To consume the webservices manually, consider the <a href=\"https:\/\/github.com\/SpringSource\/rest-shell\">rest-shell<\/a>. It is a command-shell making the navigation in your webservice as easy and fun as it could be. Here is a screenshot:<br \/>\n<a href=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/rest_shell.png\"><img decoding=\"async\" src=\"http:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/rest_shell.png\" alt=\"rest_shell\" width=\"538\" height=\"527\" class=\"aligncenter size-full wp-image-16429\" srcset=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/rest_shell.png 538w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/rest_shell-300x293.png 300w, https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2013\/08\/rest_shell-42x42.png 42w\" sizes=\"(max-width: 538px) 100vw, 538px\" \/><\/a><br \/>\nThe complete example is available on my github<br \/>\n<a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\/tree\/master\/spring-data-rest\">https:\/\/github.com\/gregorriegler\/babdev-spring\/tree\/master\/spring-data-rest<\/a><br \/>\n<a href=\"https:\/\/github.com\/gregorriegler\/babdev-spring\">https:\/\/github.com\/gregorriegler\/babdev-spring<\/a><\/p>\n<p>&nbsp;<\/p>\n<div style=\"border: 1px solid #D8D8D8; background: #FAFAFA; width: 100%; padding-left: 5px;\"><b><i>Reference: <\/i><\/b><a href=\"http:\/\/babdev.blogspot.com\/2013\/08\/spring-data-rest-in-action.html\">Spring Data REST in Action<\/a> from our <a href=\"http:\/\/www.javacodegeeks.com\/jcg\">JCG partner<\/a> Gregor Riegler at the <a href=\"http:\/\/babdev.blogspot.com\/\">Be a better Developer<\/a> blog.<\/div>\n","protected":false},"excerpt":{"rendered":"<p>What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as RESTful webservice endpoints. Unlike rails, grails or roo it does not generate any code achieving this goal. spring data-rest supports JPA, MongoDB, JSR-303 validation, HAL and many more. It is really innovative and &hellip;<\/p>\n","protected":false},"author":463,"featured_media":240,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[54,30,321],"class_list":["post-16394","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-enterprise-java","tag-restful-web-services","tag-spring","tag-spring-data"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.5 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Spring Data REST in Action<\/title>\n<meta name=\"description\" content=\"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Spring Data REST in Action\" \/>\n<meta property=\"og:description\" content=\"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html\" \/>\n<meta property=\"og:site_name\" content=\"Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2013-08-16T07:00:37+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Gregor Riegler\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@https:\/\/twitter.com\/gregor_riegler\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Gregor Riegler\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html\"},\"author\":{\"name\":\"Gregor Riegler\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6029bb9f97225ca72ec1017ca44396a0\"},\"headline\":\"Spring Data REST in Action\",\"datePublished\":\"2013-08-16T07:00:37+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html\"},\"wordCount\":687,\"commentCount\":24,\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"keywords\":[\"RESTful Web Services\",\"Spring\",\"Spring Data\"],\"articleSection\":[\"Enterprise Java\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html\",\"name\":\"Spring Data REST in Action\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"datePublished\":\"2013-08-16T07:00:37+00:00\",\"description\":\"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#primaryimage\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2012\\\/10\\\/spring-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"spring-interview-questions-answers\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/2013\\\/08\\\/spring-data-rest-in-action.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Enterprise Java\",\"item\":\"https:\\\/\\\/www.javacodegeeks.com\\\/category\\\/java\\\/enterprise-java\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"Spring Data REST in Action\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#website\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Developers Resource Center\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.javacodegeeks.com\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"contentUrl\":\"https:\\\/\\\/www.javacodegeeks.com\\\/wp-content\\\/uploads\\\/2022\\\/06\\\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/logo\\\/image\\\/\"},\"sameAs\":[\"https:\\\/\\\/www.facebook.com\\\/javacodegeeks\",\"https:\\\/\\\/x.com\\\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.javacodegeeks.com\\\/#\\\/schema\\\/person\\\/6029bb9f97225ca72ec1017ca44396a0\",\"name\":\"Gregor Riegler\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g\",\"contentUrl\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g\",\"caption\":\"Gregor Riegler\"},\"description\":\"Gregor is a passionate software engineer and RESTafarian who loves to continuously improve. He is interested in modern web development, oo-design and extreme programming. He is also serious about clean code and TDD.\",\"sameAs\":[\"http:\\\/\\\/www.beabetterdeveloper.com\",\"https:\\\/\\\/x.com\\\/https:\\\/\\\/twitter.com\\\/gregor_riegler\"],\"url\":\"https:\\\/\\\/www.javacodegeeks.com\\\/author\\\/gregor-riegler\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Spring Data REST in Action","description":"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html","og_locale":"en_US","og_type":"article","og_title":"Spring Data REST in Action","og_description":"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as","og_url":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html","og_site_name":"Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2013-08-16T07:00:37+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","type":"image\/jpeg"}],"author":"Gregor Riegler","twitter_card":"summary_large_image","twitter_creator":"@https:\/\/twitter.com\/gregor_riegler","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Gregor Riegler","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#article","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html"},"author":{"name":"Gregor Riegler","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6029bb9f97225ca72ec1017ca44396a0"},"headline":"Spring Data REST in Action","datePublished":"2013-08-16T07:00:37+00:00","mainEntityOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html"},"wordCount":687,"commentCount":24,"publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","keywords":["RESTful Web Services","Spring","Spring Data"],"articleSection":["Enterprise Java"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html","url":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html","name":"Spring Data REST in Action","isPartOf":{"@id":"https:\/\/www.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#primaryimage"},"image":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#primaryimage"},"thumbnailUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","datePublished":"2013-08-16T07:00:37+00:00","description":"What is spring-data-rest? spring-data-rest, a recent addition to the spring-data project, is a framework that helps you expose your entities directly as","breadcrumb":{"@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#primaryimage","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2012\/10\/spring-logo.jpg","width":150,"height":150,"caption":"spring-interview-questions-answers"},{"@type":"BreadcrumbList","@id":"https:\/\/www.javacodegeeks.com\/2013\/08\/spring-data-rest-in-action.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java","item":"https:\/\/www.javacodegeeks.com\/category\/java"},{"@type":"ListItem","position":3,"name":"Enterprise Java","item":"https:\/\/www.javacodegeeks.com\/category\/java\/enterprise-java"},{"@type":"ListItem","position":4,"name":"Spring Data REST in Action"}]},{"@type":"WebSite","@id":"https:\/\/www.javacodegeeks.com\/#website","url":"https:\/\/www.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Developers Resource Center","publisher":{"@id":"https:\/\/www.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/www.javacodegeeks.com\/#\/schema\/person\/6029bb9f97225ca72ec1017ca44396a0","name":"Gregor Riegler","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/secure.gravatar.com\/avatar\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g","url":"https:\/\/secure.gravatar.com\/avatar\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/f3d8d4cb0b64d8c3b228510bfc9b15e333b1e1ce941f5f5965a2bba45fea38f9?s=96&d=mm&r=g","caption":"Gregor Riegler"},"description":"Gregor is a passionate software engineer and RESTafarian who loves to continuously improve. He is interested in modern web development, oo-design and extreme programming. He is also serious about clean code and TDD.","sameAs":["http:\/\/www.beabetterdeveloper.com","https:\/\/x.com\/https:\/\/twitter.com\/gregor_riegler"],"url":"https:\/\/www.javacodegeeks.com\/author\/gregor-riegler"}]}},"_links":{"self":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16394","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/users\/463"}],"replies":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=16394"}],"version-history":[{"count":0,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/16394\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media\/240"}],"wp:attachment":[{"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=16394"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=16394"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=16394"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}