spring-data-rest

HATEOAS paths are invalid when using an API Gateway in a Spring Boot app

给你一囗甜甜゛ 提交于 2019-11-29 02:16:55
I have two spring boot applications where one of them is acting as an API Gateway (as discussed here Spring Example ). The other which is wired into the first one is exposing a profile service using spring-data-rest (spring-data-neo4j-rest). The first application is starting on port 8080 and is using zuul to route requests to the second as follows: zuul: routes: profiles: path: /profiles/** url: http://localhost:8083/profiles/ This all works fine and requests to http://localhost:8080/profiles are being served from the second app. The problem though is that the HATEOAS links in the response are

How to add links to Spring Data REST projections?

Deadly 提交于 2019-11-29 02:04:45
I have created a Spring Data Rest projection (not an excerpt projection) and need to add some links to it only as these links do not hold significance with other projections of same entity nor with the entity itself. How can we do this as far as I know using ResourceProcessor I can add links to only entities, is it possible to add links for only that projection ? fortm It seems it is possible just to create a ResourceProcessor dedicated to a projection and I could create 3 ResourceProcessors one for each projection and one for entity itself and they get called depending on which projection is

How to make an advanced search with Spring Data REST?

[亡魂溺海] 提交于 2019-11-29 01:40:34
My task is to make an advanced search with Spring Data REST. How can I implement it? I managed to make a method to do a simple search, like this one: public interface ExampleRepository extends CrudRepository<Example, UUID>{ @RestResource(path="searchByName", rel="searchByName") Example findByExampleName(@Param("example") String exampleName); } This example works perfectly if I have to go simply to the url: .../api/examples/search/searchByName?example=myExample But what I have to do if there are more than one field to search? For example, if my Example class has 5 fields, what implementation

Multiple Repositories for the Same Entity in Spring Data Rest

╄→гoц情女王★ 提交于 2019-11-29 01:10:29
Is it possible to publish two different repositories for the same JPA entity with Spring Data Rest? I gave the two repositories different paths and rel-names, but only one of the two is available as REST endpoint. The point why I'm having two repositories is, that one of them is an excerpt, showing only the basic fields of an entity. The terrible part is not only that you can only have 1 spring data rest repository (@RepositoryRestResource) per Entity but also that if you have a regular JPA @Repository (like CrudRepository or PagingAndSorting) it will also interact with the spring data rest

How to update reference object in Spring-data rest?

寵の児 提交于 2019-11-29 00:01:57
问题 Example: class Course and Teacher having many-to-one relationship, how to change teacher for a certain course via Spring-data rest? GET http://localhost:7070/study-spring-data/course/2 Response: { "name" : "CSCI-338 Hardcore Java", "_links" : [ { "rel" : "course.Course.teacher", "href" : "http://localhost:7070/study-spring-data/course/2/teacher" }, { "rel" : "self", "href" : "http://localhost:7070/study-spring-data/course/2" } ] } GET http://localhost:7070/study-spring-data/course/2/teacher

Spring Scheduling - Cron expression for everyday at midnight not working?

人走茶凉 提交于 2019-11-28 22:49:47
问题 I am trying to schedule a task in Spring which is to be run everyday at midnight. I followed the official guide from Spring and made the scheduler class as below: @Component public class OverduePaymentScheduler { @Scheduled(cron = "0 0 0 * * *") public void trackOverduePayments() { System.out.println("Scheduled task running"); } } However the task does not run when the clock hits 12am. I got the cron expression from the documentation for quartz scheduler at this link. The scheduler is

How to get old entity value in @HandleBeforeSave event to determine if a property is changed or not?

ぐ巨炮叔叔 提交于 2019-11-28 21:10:47
问题 I'm trying to get the old entity in a @HandleBeforeSave event. @Component @RepositoryEventHandler(Customer.class) public class CustomerEventHandler { private CustomerRepository customerRepository; @Autowired public CustomerEventHandler(CustomerRepository customerRepository) { this.customerRepository = customerRepository; } @HandleBeforeSave public void handleBeforeSave(Customer customer) { System.out.println("handleBeforeSave :: customer.id = " + customer.getId()); System.out.println(

Spring-Data-Rest Validator

主宰稳场 提交于 2019-11-28 20:36:14
I have been trying to add spring validators to a spring-data-rest project. I followed along and setup the "getting started" application via this link: http://spring.io/guides/gs/accessing-data-rest/ ...and now I am trying to add a custom PeopleValidator by following the documents here: http://docs.spring.io/spring-data/rest/docs/2.1.0.RELEASE/reference/html/validation-chapter.html My custom PeopleValidator looks like package hello; import org.springframework.validation.Errors; import org.springframework.validation.Validator; public class PeopleValidator implements Validator { @Override public

Jackson @JsonFormat set date with one day less

浪尽此生 提交于 2019-11-28 17:34:39
问题 I have been used Spring Date Rest with Spring Boot in my project. This project has a object and I have used the annotation @JsonFormat to format the date field that will be received from my Json. The format of field Date is "dd/MM/yyyy". When I send in my json the value "08/07/1980" the Jackson convert to the value "07/07/1980". The problem is that @JsonFormat set the date with one day less This is my source code @Temporal(TemporalType.DATE) @JsonFormat(shape = JsonFormat.Shape.STRING,

kotlin data class + bean validation jsr 303

↘锁芯ラ 提交于 2019-11-28 17:26:39
问题 I'm trying to get Kotlin working with jsr 303 validation on a spring-data-rest project. Given the following data class declarartion : @Entity data class User( @Id @GeneratedValue(strategy = javax.persistence.GenerationType.AUTO) var id: Long? = null, @Size(min=5, max=15) val name: String ) The @Size annotation has no effect here, making me able to save a user with a name of 1 character. It works well when executing the very same example but in a Java class instead of Kotlin. This makes me