Currently I want to access the objects inside StaxEventItemReader. This is done by using StaxEventItemReader.read() (xml-file has 50 objects/items), so that I can do something with these objects. The question is how you can correctly iterate over the items of StaxEventItemReader? Originally I had something li…
Tag: spring
How to make multiple Spring HandlerInterceptors execute in a specific order
I’m currently working on a Spring boot project. I have a dependency on a library project that has an interceptor(LibraryProjectInterceptor.java) and a public class LibraryProjectConfig implements WebMvcConfigurer and overrides the addInterceptors() method to add the LibraryProjectInterceptor to the Inte…
explain how JobLauncherApplicationRunner class works?
I was reading the source code of JobLauncherApplicationRunner. according to my understanding when we use Spring boot + Spring batch, this class is used to find all the jobs in the application context and use SimpleJobLauncher to execute jobs in startup. I found some cases that contradicts my previous knowledg…
@Qualifier in Spring on top of classes
I’ve been playing around in Spring/Spring Boot and notice something strange which I can’t really dig on my own, so any help would be appreciated. Let’s say we have the following I am running a Spring Boot program, so everything is set up correctly, this is for simplicity. At this point, if w…
spring boot boostrap bean override
In my spring.factories I have such a definition: In MyBootstrapConfiguration I have : Now in my test (junit-5 and @SpringBootTest), I would like to override this bean. Notice the @ConditionalOnMissingBean… If I can hook somehow to a “before” my bootstrap is started, to provide that ApiClient…
What is the purpose of mockMvc .contentType(MediaType.APPLICATION_JSON)?
I don’t understand the point of this method and can’t find any info about it. What is the reason of using it, especially for void methods like in example below? I’ve tried deleting it in my tests and seems like everything is the same. Test Controller to be tested Answer The contentType metho…
How to limit concurrent http requests with Mono & Flux
I want to handle Flux to limit concurrent HTTP requests made by List of Mono. When some requests are done (received responses), then service requests another until the total count of waiting requests is 15. A single request returns a list and triggers another request depending on the result. At this point, I …
Hibernate simply adding elements to manytomany from JSON
I want to add elements in my manytomany association via a request without loading each added element. I am using a custom join table. [Code will be added at the bottom] So for example this is the JSON I get: So there is one HomeworkMaterial. If I send this as POST to the server nothing happens (as expected). …
Ways to implement Google Pub Sub
I found these 3 ways for implementing messaging with Google Pub Sub: with client libraries https://cloud.google.com/pubsub/docs/publisher with spring integration message channels and PubSubTemplate API https://dzone.com/articles/spring-boot-and-gcp-cloud-pubsub without message channels but with PubSubTemplate…
Some doubts about this Spring Batch @Scheduled() annotation and how to manually start a Spring Batch job?
I am pretty new in Spring Batch and I have the following doubts about how to schedule the job start at a specific time. Into my project I have this SpringBatchExampleJobLauncher class: As you can see it contains the runSpringBatchExampleJob() method running the job at a specific time set by the cron expressio…