spring-data-rest

Spring Data Rest 2.1.0 Cannot POST or PUT Complex Resource

假如想象 提交于 2019-12-23 05:19:27
问题 EDIT: This appears to be happening with PUTs as well. Using spring-data-rest-webmvc version 2.1.0.BUILD-SNAPSHOT I have found that I am unable to POST a resource with a relation pointing to an already existing resource. I have 2 such entities which require references to be instantiated and POSTing to either of their endpoints results in the behavior below. POSTing a resource without required references works well. I did a bit of digging and it appears that

spring-data-rest-webmvc 2.0.0 - RepositoryRestExporterServlet missing

。_饼干妹妹 提交于 2019-12-23 03:48:10
问题 I'm trying to create a REST web service with spring-data-rest-webmvc 2.0.0. I'm following the handbook "Spring in Practice" where you use the version 1.0.0. In this handbook, it define the exporter servlet in web.xml as below: <web-app ...> ... <servlet> <servlet-name>api</servlet-name> <servlet-class>org.springframework.data.rest.webmvc.RepositoryRestExporterServlet</servlet-class> <load-on-startup>1</load-on-startup> </servlet> <servlet-mapping> <servlet-name>api</servlet-name> <url-pattern

Combine Dynamic datasource routing with spring-data-rest

假如想象 提交于 2019-12-23 02:38:11
问题 I'm using Dynamic datasource routing as indicated in this blog post: http://spring.io/blog/2007/01/23/dynamic-datasource-routing/ This works fine, but when I combine it with spring-data-rest and browsing of my generated repositories I (rightfully) get an exception that my lookup-key is not defined (I do not set a default). How and where can I hook into the Spring data rest request handling to set the lookup-key based on 'x' (user authorizations, path prefix, or other), before any connection

Spring Data Rest: custom Converter<Entity, Resource> is never invoked

让人想犯罪 __ 提交于 2019-12-23 02:07:23
问题 I'm trying to implement a custom Converter for an Entity to a Resource object with Spring Data Rest, but the Converter is never invoked. I'm following this documentation: If your project needs to have output in a different format, however, it’s possible to completely replace the default outgoing JSON representation with your own. If you register your own ConversionService in the ApplicationContext and register your own Converter, then you can return a Resource implementation of your choosing.

How to use List in endpoint exported by Spring Data REST?

时间秒杀一切 提交于 2019-12-22 14:37:22
问题 I have 2 objects, Foo and Bar (a Foo is @ManyToOne with Bar), and a very basic repository interface in Spring Boot 2.0, and a method: List<Foo> findByBarIn(@Param("bar") List<Bar> bar); This gets mapped by Spring to an endpoint called /foos/search/findByBarIn I can specify a single bar doing something like GET http://host/foos/search/findByBarIn?bar=http://host/bars/33 (where 33 is the ID the of the Bar entity) But, how can I specify multiple bars? I've tried: (with no success) GET http:/

How to write paginated controller that expose resource or list of resource in spring-data-hatoas

一曲冷凌霜 提交于 2019-12-22 13:32:52
问题 Using spring-data, I want to write two method for my Person entity. Person.java: public class Person { @Id String id; String name; Integer age; // getters/setters omitted for clarity } I have written also a PersonResouce : public class PersonResource extends Resource<Person> { public PersonResource(Person content, Link... links) { super(content, links); } } I have also added a PersonResourceAssembler : public class PersonResourceAssembler extends ResourceAssemblerSupport<Person,

How to write paginated controller that expose resource or list of resource in spring-data-hatoas

非 Y 不嫁゛ 提交于 2019-12-22 13:32:19
问题 Using spring-data, I want to write two method for my Person entity. Person.java: public class Person { @Id String id; String name; Integer age; // getters/setters omitted for clarity } I have written also a PersonResouce : public class PersonResource extends Resource<Person> { public PersonResource(Person content, Link... links) { super(content, links); } } I have also added a PersonResourceAssembler : public class PersonResourceAssembler extends ResourceAssemblerSupport<Person,

Spring Data Rest - PUT is not working for associated reference types?

江枫思渺然 提交于 2019-12-22 09:56:07
问题 I have the following domain class implemented for a Spring Data Rest project. @Entity @Data public class Address { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "id") private long addressID; private String houseName; private String apartmentNumber; @ManyToOne private City city; @ManyToOne private Country country; } Now I am creating an Address resource by sending a POST with following JSON. { "houseName":"Some House", "apartmentNumber":"13 B", "city": "http:/

Spring Data Rest Custom Links on Resource

耗尽温柔 提交于 2019-12-22 09:48:46
问题 The Spring Data Rest repository notes that Custom Links can be added to an Entity as below: http://docs.spring.io/spring-data/rest/docs/current/reference/html/#_the_resourceprocessor_interface Example Given: @Bean public ResourceProcessor<Resource<Person>> personProcessor() { return new ResourceProcessor<Resource<Person>>() { @Override public Resource<Person> process(Resource<Person> resource) { resource.add(new Link("http://localhost:8080/people", "added-link")); return resource; } }; }

Using a Spring Data Rest @Projection as a representation for a resource in a custom controller

南笙酒味 提交于 2019-12-22 09:09:30
问题 Is there any way to use a @Projection interface as the default representation for a resource in SDR? Either through the SDR repositories or through a custom controller? It used to be possible in a custom controller to do this by injecting a ProjectionFactory and using the createProjection method, but this has been broken by a recent Spring Data Rest update. I would like to enforce a particular view on an entity, and the SDR projections seem like an ideal method for doing this, especially in