Category "spring"

How to write a unit test for spring specification?

I created a builder class which construct Specifications object. It is used for creating queries for JpaSpecificationExecutor. The builder is used, because I ha

Unable to register MBean

I am writing integration tests for a spring-boot application, and I am using a base test class for common methods and all the other common stuff. Something like

Combine Pagination of Two Different Entities With different size

I'm working on a problem where i have to do pagination of two data lists. ex. psudo code int recordsPerPage = 100; // this is dynamic int currentPage = 1; // th

spring reactive retry with exponential backoff conditionally

Using spring reactive WebClient, I consume an API and in case of response with 500 status I need to retry with exponential backoff. But in Mono class, I don't s

How to get relationship data with spring boot rest api?

I'm building a REST API with Spring Boot to retrieve boat information. I'm using Spring Data Rest and Spring Data JPA. When I get the data from the API, I don't

Return id of Many-To-One relation in Java Spring rest api

I have 2 models: Student and Teacher. Teacher has One-To-Many relation with Student, Student has Many-To-One with teacher. I want to build API what gonna have i

Difference between @Mock, @MockBean and Mockito.mock()

When creating tests and mocking dependencies, what is the difference between these three approaches? @MockBean: @MockBean MyService myservice; @Mock: @Mock

Got bad greeting from SMTP host: smtp.yandex.ru, port: 465, response: [EOF]] with root cause Yandex

I use brand new spring boot project with next Maven dependency <dependency> <groupId>org.springframework.boot</groupId>

Mixed Content error because of Keycloak default login redirection

INFORMATION NEEDED: I use Keycloak (Docker version) behind a Spring project. (The client side of this project is React and communication between client and ba

How to add scheduled job to all nodes in java springboot cluster?

We have two springboot servers. We use nginx so that the user request will be sent to one of the server node. Now we want to achieve that: After user inputs thr

How to use math.max in thymeleaf to find maximum number?

While trying to use max function in thymeleaf I got OGNL expressionn everytime. I'm not even sure if we can use functions like max/min in thymeleaf. Tried to lo

How to add headers(autherization header) in Prometheus.yml file while configuring spring application

Running my application on localhost with this url -> http://localhost:8081/my-service-name After configuring prometheus, I am getting the metrics on postman

Apache Camel: MethodNotFoundException, Failed to invoke method on null due to: MethodNotFoundException

I try following a video tutorial for Apache Camel education and trying aggregate queue objects in a next way: @Component public class AggregationRoute extends R

JSONObject always returns "empty": false

There is a Spring Rest Controller : @RestController @RequestMapping("secanalytique") public class SectionAnalytiqueController { @GetMapping(value = "/sect

CustomDeserializer has no default (no arg) constructor

I am consuming a REST Api with RestTemplate. The response I'm getting from the API has lots of nested objects. Here's a little snippet as an example: "formular

Getting a 400 bad request response when submitting a form in Thymeleaf to my spring boot application

I am creating a Spring boot application with a thymeleaf front-end. I am trying to create an object of type "expense" (seen in the code snippet below) but, when

Send an image in the mail using thymeleaf

In my application I would want to send emails using javamail. I use Thymeleaf so that I can send some data. When sending the email, I want the background to be

How to call repository method in entity listener

I'm trying to make call to repository inside my Entity Listener, when I call repository.findById() method inside my @prePersist method the same method is callin

Spring Boot build image failure for native image

Using spring boot 2.6.2, with java17, trying to create native image but it fails with below error. I am building it on windows 11 machine with docker desktop i

How to get image in response with postman

I have an endpoint to get the image i uploaded earlier, it works but not well I don't know if i can get the image in response my controller endpoint: @PreAuth