My API is returning me this: The problem is, I would like to, on the array that is represented by the second ID, return a error message, as there is no data in it. Something like this: My code is as follows: With this, I can’t seem to override the specific response, as it is an List of the Entity(Health…
Tag: spring
org.springframework.beans.factory.UnsatisfiedDependencyException: Error creating bean with name ‘messageSender’
Error while trying to publish a message from spring boot to Google cloud platform pub/sub. I was trying to publish a message to the Google Cloud Platform pub/sub messaging queue. I was getting the following errors while trying to run the application.Please help. I was using only a single Java Class file. Thea…
Thymeleaf fragment processor and Spring 5
Could somebody, please, help with Thymeleaf? I need to create a template layout and I’ve got stuck with <div th:fragment=”content”></div>. The point is layout:fragment doesn’t replace code on the dashboard page. By the way, other processors like layout:decorate or th:replac…
Spring Boot 2 Multiple Datasource – work only the one with @Primay annotation
I have a problem, I’m trying to use two Oracle databases in spring boot using DataSource, The DataSource wiht the @Primay annotation works fine but the oher one only gives me: I don’t have idea what I should do now. Any help will be welcomed. Thanks! application.properties pom.xml DatabaseConfigur…
Java Spring Boot – how to seed a database like in PHP Laravel
I’m trying to learn Java Spring Boot. I’m coming from PHP Laravel and the one thing I miss about the framework is how easy it is to make database seeders and factories etc. I’m trying to figure out a way where I can seed my h2 db so that every time the application does a hot reload it will c…
Facing ambiguity in spring constructors, second constructor is getting called
I’m facing an issue which is producing an output which is not exactly per the norm. I have read that in case of constructor ambiguity the first constructor gets called. But I’m facing a completely different issue. My class – XML file – Main code – Output- My only concern here is …
RestTemplate get list from specific json structure
The json is of this structure: I have a DTO of the form I want to parse the array into List and ignore data. This is the code: But I get this exception Answer I would suggest you changing your model as follows: And your test also:
Spring Boot returns Error 404 even though mapping has been set
I downloaded a Spring Boot project from Spring Initializr. I am trying to call sayHello() method in DemoApplication.java. Here are my code. DemoApplication.java pom.xml When I run on http://localhost:8080/hello it returns error 404 page. It does not call sayHello() method even though I have set the GET mappin…
Spring Data JPA sorting by property without hardcoding
I have entity that has several fields: I want to have code which is capable to sort by foo and sort by bar depending on the request. I know that there is tool that could be used like this: But it seems like this approach is not perfect because field names are hardcoded and in the case that some field
is it possible to register route filter in the application.properties config in spring gateway
I define a custom filter in spring gateway project, now I found I have to register the custom filter in the code like this: if I do not register the custom filter, the filter will not make effect and work as expect. But I already config the route in application.properties like this: I think we should not defi…