I have a couple of microservices developed using spring boot and each has its own Postgres database. These microservices exchange data with a CDC mechanism provided by debezium platform through kafka broker and kafka connect. I have a microservice A that stores some entities with a BigDecimal attribute. Another microservice B depends on the data stored by A so it
Tag: spring
java.lang.NoSuchMethodError: org.json.JSONObject.(Ljava/lang/Object;)V
I have a basic SpringBoot 2.1.5.RELEASE app. Using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file with some RestControllers. In 1 of the controller this is the body I send: so I create this class to send it as a RequestBody: and public class HotelswitchHotelOrderRequestBody { and But i have this error: pom.xml:
How to pass Spring profile to Spring Boot application run by Jenkins Job?
I need to run a Spring Boot app using different configuration files. In local I can do it with the following JVM Option: What’s the way to do this when I run the app from a Jenkins job? Answer With the assumption that user knows .jenkins file, I provide below the code snippet. For more details and reference, check below
Dynamically add property sources to SpringBootTest
Similar to Springboot unit test set @Configuration Properties dynamically but the context is different. In my case I have a TestContainer running a custom MySQL database that is prepopulated with a lot of data (not using the SQL batch loading approach because the data is an anonymized copy of production and doing it through SQLs makes the boot up time
Spring Boot graceful shutdown
I am developing a Spring Boot application backed by embedded Tomcat and I need to develop a graceful shutdown with the following steps: stop processing new HTTP requests (stop web container) process all already accepted requests shutdown Spring ApplicationContext *do the steps above sequentially (one by one) How can I achieve this? P.S. Spring Boot 1.5.20.RELEASE, Java 8 Answer I
Route order in Spring Cloud Gateway
We are implementing routes programmatically using a implementation of RouteDefinitionLocator. We have two services which should register at the same route path, where one of them is meant as a fallback if the other one does not exist. The preferred route with the specific path is: And the more general one, which should only fire if other route was found:
Making multiple requests with Spring WebClient
So my goal is to use WebClient to make multiple concurrent requests, wait until they’re all completed, then combine the results. Here is what I have so far: Basically my goal is to combine all the items from each of the feeds to create one unified feed. However, I am not quite sure what to do after the call to
How to catch deserialization error in Kafka-Spring?
I’m getting up an application consuming kafka messages. I followed Spring-docs about Deserialization Error Handling in order to catch deserialization exception. I’ve tried the failedDeserializationFunction method. This is my Consumer Configuration Class This is the BiFunction Provider When I send just one corrupted message on the topic I got this error (in loop): org.apache.kafka.common.errors.SerializationException: Error deserializing key/value I understood that
JPA Lazy loading is not working in Spring boot
I googled a lot and It is really bizarre that Spring Boot (latest version) may not have the lazy loading is not working. Below are pieces of my code: My resource: My service: My Entity: And when debugging, I still getting all lazy loaded attributed loaded. See image below. One of my questions is could Jackson be involved in such
How can I use @WithMockUser and pass my username and password from my properties file?
I am writing an integration test where the application has a basic auth applied with spring security. I am using @WithMockUser to tell mockMVC how to authenticate with my endpoints. This works but I am wondering if I can replace those strings with references to the values in my application.properties file similiar how you can do: Is the above possible?