I am starting to build a Microservice API Gateway, and I am considering Spring Cloud to help me with the routing. But some calls to the Gateway API will need multiple requests to different services. Lets say I have 2 services: Order Details Service and Delivery Service. I want to have a Gateway endpoint GET /orders/{orderId} that makes a call
Tag: spring
How to apply the PathPatternParser introduced in Spring 5?
I want to create a GET request that takes a filepath as a path variable. As described in the Spring documentation found here, this should be possible by using the following: /resources/{*path}. I am using Spring Boot 2.1.2 which uses Spring 5. However when I set up my controller method like this, the request doesn’t match the route. An expected
How to catch a @JsonFormat exception in spring and handle it gracefully to process the payload?
I have a spring app in which I am using the @JsonFormat annotation to deserialize a date format. But when I sent an array of elements my entire payload fails even if one of the entries have an invalid date. Is there a way I can surpass this by gracefully handling this exception, by either replacing the failed date with
Unable to use custom HttpMessageNotReadableException error message in Spring Boot
I’m currently trying to provide custom messages for exceptions, but ran into an issue with HttpMessageNotReadableException. I have an ErrorDetails class: I also have a custom exception handler: But when i try to post a bad request, for example, with a field that should have a integer value I pass a string in the JSON it still returns the default
@PostConstruct and @PreDestroy annotations do not work
I have TennisCoach class: And such main class: Expected output is: Inside default constructor Inside postconstructor DailyFortune Practice your backhand volley Inside predestroyer But I get this: Inside default constructor DailyFortune Practice your backhand volley It seems like @PostContruct and @PreDestroy annotations do not work correctly. I cannot find the reason of my problem. Answer If you use java 9+
Spring generate progressive unique int for entity
I am working on a REST api in Spring, and I’m required to save an entity Document with a protocol number which consists in: Here is the model: I have come up with this solution: In other words I’m saving the object and updating it using the id the DB created, but I wonder if there is a better way
Validation not working on spring boot and hibernate
I am new to spring boot and hibernate.I have declared a model class Office which is : I have declared my first main starting class as: My controller class is: I have a office.jsp page which is: My pom.xml is: When I click the submit button then if the input field in my form are empty,I wanted to validate my
How to implement Decorator pattern in Spring Boot
I know how to implement and use a decorator pattern without Spring. Because in this pattern you yourself control the process of creating components and you can perform dynamic behavior adding. Below is an example of implementation without using Spring: I am interested in how to implement the same example but with the help of spring beans. Because I don’t
Accessing spring bean proxy reference itself
I have an issue with @Cacheable and @CacheEviction annotations. When I call these methods in the bean where they are declared, the aop part is not getting executed. The underlying reason for this is that the bean access to its own instance itself, instead of accessing the spring proxy. I have read this question where it is said that in
JPA Bidirectional relationship throws java.lang.StackOverflowError: null
i’m trying to relate two entities with JPA, when i run the project don’t throws me errors but when i request the method that get me the Voters of a Comunity Leader i get the next Exception: I’ts like a loop, i don’t khow how to resolve this. Here are my classes: 1)Leader Entity : 2)Voter Entity : 3)LeaderController :