spring-data-rest

Avoid showing Spring Framework specific services as part of Swagger interface

六眼飞鱼酱① 提交于 2020-01-03 02:22:20
问题 I am using spring-boot-starter-parent 1.3.3.RELEASE. I am unable to disable the following endpoints in Swagger UI. Need To Disable:- Entity Metadata Services profile-controller repository-controller I disabled the following endpoints using the code.. Disabled endpoints:- environment-manager-mvc-endpoint generic-postable-mvc-endpoint restart-mvc-endpoint Code:- public Docket appHierarchyServiceApi() { return new Docket(DocumentationType.SWAGGER_2) .select() .apis(Predicates.not

Spring not loading data even with FetchType.EAGER set

梦想的初衷 提交于 2020-01-02 05:47:10
问题 I have two models I'm trying to get data back from a REST API (Pet and Media). I'm trying to get the oneToMany relationship between pet and media eagerly loaded via the FetchType.EAGER annotation, but the data doesn't appear when I write the MediaRepository. If I don't implement that file, the media relationship and data comes back in the response. With MediaRepository.java Implemented, GET /pets returns: { "id": 72, "name": "Spot", "description": "Annoying as hell", "media": [], <-- why is

Spring Data REST - difference between @PrePersist and @HandleBeforeCreate?

£可爱£侵袭症+ 提交于 2020-01-02 03:17:07
问题 I use Spring Data Rest over JPA mappings. JPA provides @PrePersist annotation for methods to be called before the persistence of en entity in the DB. Spring Data Rest provides @HandleBeforeCreate annotation for method to be called when catching an entity creation event. This seems rather equivalent to me. When should I use one and when should I use the other ? 回答1: @HandleBeforeCreate is only called when a REST request comes in but @PrePersist is called during the entities lifecycles. So, if

Spring Data Rest (SDR) error: PersistentEntity must not be null

我怕爱的太早我们不能终老 提交于 2020-01-02 03:10:29
问题 I'm working to expose my spring data repositories via SDR. When I navigate to my rest url (http://localhost:8080/trxes), I get an error: {"cause":null,"message":"PersistentEntity must not be null!"} On closer inspection of the spring data source, I see that the getRepositoryFactoryInfoFor() method returns empty repository information i.e. private RepositoryFactoryInformation<Object, Serializable> getRepositoryFactoryInfoFor(Class<?> domainClass) { Assert.notNull(domainClass, "Domain class

Exclude some fields of Spring-data-rest resource

大兔子大兔子 提交于 2020-01-01 02:25:09
问题 I'm trying to use Spring-data-rest with spring-data-mongodb to expose read-only resources. The problem I met, is that I want to have different views of my documents. Let's say I have some private information in a document, I don't want to expose them publicly. So I tried several ways. I read this post https://spring.io/blog/2014/12/02/latest-jackson-integration-improvements-in-spring describing how to use JsonView in order to select the fields we want to expose. I've tried like this :

How can you customise self, parent, children links in spring data rest with neo4j

我的未来我决定 提交于 2019-12-31 02:35:07
问题 I am using spring data rest to create an API over neo4j. I don't want to expose nodeId in my URLs, therefore I have a UUID instead. More info on here: How can I change neo4j Id to UUID and get finder methods to work? How can I modify the auto-generated links by the spring-data-rest to reflect the change to UUID instead of nodeId? Thanks ----UPDATED--- public class CustomBackendIdConverter implements BackendIdConverter { @Autowired PracticeAreaRepository practiceAreaRepository; @Override

PUT and POST fail on unknown properties Spring different behavior

ぐ巨炮叔叔 提交于 2019-12-30 07:56:27
问题 I am writing Spring Boot application using Spring Data Rest repositories and I want to deny access to resource if request body contains JSON that has unknown properties. Definition of simplified entity and repository: @Entity public class Person{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String firstName; private String lastName; /* getters and setters */ } @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface

PUT and POST fail on unknown properties Spring different behavior

假装没事ソ 提交于 2019-12-30 07:55:53
问题 I am writing Spring Boot application using Spring Data Rest repositories and I want to deny access to resource if request body contains JSON that has unknown properties. Definition of simplified entity and repository: @Entity public class Person{ @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String firstName; private String lastName; /* getters and setters */ } @RepositoryRestResource(collectionResourceRel = "people", path = "people") public interface

Canonical _links with Spring HATEOAS

怎甘沉沦 提交于 2019-12-30 06:53:07
问题 We're building a RESTful web service similiar to the spring.io guide "Accessing JPA Data with REST". To reproduce the sample outputs below, it suffices to add a ManyToOne -Relation to Person as follows: // ... @Entity public class Person { @Id @GeneratedValue(strategy = GenerationType.AUTO) private long id; private String firstName; private String lastName; @ManyToOne private Person father; // getters and setters } A GET request after adding some sample data yields: { "firstName" : "Paul",

Custom HTTP Methods in Spring MVC

佐手、 提交于 2019-12-30 04:45:05
问题 I am trying to create a custom Spring MVC Controller for a resource that would handle the COPY HTTP method. @RequestMapping accepts only the following RequestMethod values: GET, HEAD, POST, PUT, PATCH, DELETE, OPTIONS and TRACE. Is there any recommended way of handling custom HTTP methods in Spring MVC Controller? 回答1: The Servlet specification allows only for GET , HEAD , POST , PUT , DELETE , OPTIONS or TRACE HTTP methods. This can be seen in the Apache Tomcat implementation of the Servlet