All Questions
Tagged with spring-boot spring-webflux
2,470
questions
100
votes
20
answers
156k
views
how to log Spring 5 WebClient call
I'm trying to log a request using Spring 5 WebClient. Do you have any idea how could I achieve that?
(I'm using Spring 5 and Spring boot 2)
The code looks like this at the moment:
try {
return ...
65
votes
2
answers
74k
views
Mono switchIfEmpty() is always called
I have two methods.
Main method:
@PostMapping("/login")
public Mono<ResponseEntity<ApiResponseLogin>> loginUser(@RequestBody final LoginUser loginUser) {
return socialService....
63
votes
2
answers
3k
views
Using spring HATEOAS with spring webflux Functional Web Framework (reactor-netty)
Can we use spring HATEOAS on top of RouterFunction ? I imagine that we can specify the resource but what will be the equivalent of the linkto(Controller.class) ? or is there any equivalent to specify ...
60
votes
18
answers
126k
views
Spring Boot 2.0 disable default security
I want to use Spring Security for JWT authentication. But it comes with default authentication. I am trying to disable it, but the old approach of doing this - disabling it through application....
60
votes
12
answers
108k
views
How to log request and response bodies in Spring WebFlux
I want to have centralised logging for requests and responses in my REST API on Spring WebFlux with Kotlin. So far I've tried this approaches
@Bean
fun apiRouter() = router {
(accept(MediaType....
53
votes
1
answer
27k
views
Can I use SpringMvc and webflux together?
I would like to use 2 approaches(reactive and standard) in one project.
I tried to migrate one REST API endpoint to reactive webflux and test performance before migrate rest of them. But it didn't ...
47
votes
2
answers
22k
views
Difference between @Controller and RouterFunction in Spring 5 WebFlux
There are two ways to expose HTTP endpoints in spring 5 now.
@Controller or @RestController by making the controller's class, e.g.
@RestController
@RequestMapping("persons")
public class ...
44
votes
2
answers
27k
views
Cant autowire `WebTestClient` - no auto configuration
We are using spring framework 5 and spring boot 2.0.0.M6 and we are also using WebClient for reactive programming. We created test methods for our reactive rest endpoints and so I looked up for some ...
42
votes
3
answers
68k
views
Deserialize a json array to objects using Jackson and WebClient
I have a problem during the deserialization of a json array using Spring.
I have this json response from a service:
[
{
"symbol": "XRPETH",
"orderId": 12122,
"...
42
votes
2
answers
20k
views
How to make reactive webclient follow 3XX-redirects?
I have created a basic REST controller which makes requests using the reactive Webclient in Spring-boot 2 using netty.
@RestController
@RequestMapping("/test")
@Log4j2
public class TestController {
...
40
votes
11
answers
113k
views
How to extract response header & status code from Spring 5 WebClient ClientResponse
I am new to Spring Reactive framework & trying to convert Springboot 1.5.x code into Springboot 2.0. I need to return response header after some filtering, body & status code from Spring 5 ...
38
votes
3
answers
34k
views
Spring boot Webclient's retrieve vs exchange
I have started using WebClient in my Spring boot project recently.
Can somebody throw some light on the differences/usages between exchange and retrieve methods in WebClient.
I understand that ...
35
votes
8
answers
63k
views
Spring Webflux + JPA: Reactive Repositories are not supported by JPA
I am getting error when I start my app JPA: Reactive Repositories are not supported by JPA.
My Pom has below dependencies and i am using Spring Boot 2.0.5
<dependency>
<groupId&...
32
votes
2
answers
55k
views
How to post request with spring boot web-client for Form data for content type application/x-www-form-urlencoded
How To use spring boot webclient for posting request with content type application/x-www-form-urlencoded
sample curl request with content type `application/x-www-form-urlencoded'
--header 'Content-...
31
votes
4
answers
78k
views
How to send request body in spring-boot web client?
I'm facing some problem while sending request body in spring boot web client. Trying to send body like below:
val body = "{\n" +
"\"email\":\"[email protected]\",\n" +
"\"id\":1\n"...
30
votes
2
answers
22k
views
How to prevent embedded netty server from starting with spring-boot-starter-webflux?
I want to establish a communication between a client and server application using Springs new reactive webflux extension.
For dependency management I use gradle.
My build.gradle file on the server, ...
30
votes
3
answers
28k
views
Spring Webflux and @Cacheable - proper way of caching result of Mono / Flux type
I'm learning Spring WebFlux and during writing a sample application I found a concern related to Reactive types (Mono/Flux) combined with Spring Cache.
Consider the following code-snippet (in Kotlin):...
29
votes
8
answers
73k
views
Suddenly Springfox Swagger 3.0 is not working with spring webflux
Application was working with Springfox Swagger 3.0 few days back. Suddenly it is stopped working. The Jar file which was created before a week is still working but now when we try to build a new Jar ...
28
votes
4
answers
38k
views
Spring WebFlux throws 'producer' type is unknow when I return value in the response body
I'm using Spring Boot with Kotlin, and now trying to get status value from a GET restful service by passing a handler for a reactive service.
I can see that the handler I'm passing is in the request, ...
27
votes
5
answers
15k
views
Spring Webflux, How to forward to index.html to serve static content
spring-boot-starter-webflux (Spring Boot v2.0.0.M2) is already configured like in a spring-boot-starter-web to serve static content in the static folder in resources. But it doesn't forward to index....
26
votes
3
answers
22k
views
Does the use of Spring Webflux's WebClient in a blocking application design cause a larger use of resources than RestTemplate
I am working on several spring-boot applications which have the traditional pattern of thread-per-request. We are using Spring-boot-webflux to acquire WebClient to perform our RESTful integration ...
25
votes
6
answers
18k
views
Configured ObjectMapper not used in spring-boot-webflux
I have mixins configured in my objectmapperbuilder config, using the regular spring web controller, the data outputted according to the mixins.
However using webflux, a controller with a method ...
25
votes
5
answers
62k
views
Get API response error message using Web Client Mono in Spring Boot
I am using webflux Mono (in Spring boot 5) to consume an external API. I am able to get data well when the API response status code is 200, but when the API returns an error I am not able to retrieve ...
25
votes
2
answers
18k
views
Reactive Spring WebClient - Making a SOAP call
I am looking to make a SOAP call from spring reactive webclient.
I couldn't find any documentation for it. Wondering what would the approach. Right now I am thinking
Construct the SOAP message ...
24
votes
2
answers
97k
views
How to get response json from Spring WebClient
I've been trying to follow the simplest tutorials out there for how to use WebClient, which I understand to be the next greatest thing compared to RestTemplate.
For example, https://www.baeldung.com/...
24
votes
3
answers
6k
views
How to do sequence of operations and ensure one operation is complete before next one in Spring Reactor web app?
I have Spring Boot 2 web app in which I need to identify site visitor by cookie and gather page view stats. So I need to intercept every web request. The code I had to write is more complex than call ...
22
votes
1
answer
17k
views
Spring 5 WebFlux Mono and Flux
In Spring 5 I just know Spring WebFlux Handler method handles the request and returns Mono or Flux as response.
@Component
public class HelloWorldHandler {
public Mono<ServerResponse> ...
22
votes
2
answers
25k
views
Don't spring-boot-starter-web and spring-boot-starter-webflux work together?
When I start to learn the spring-webflux, I have the question about this component.
I built a simple project, using maven to manage it. I addded the dependencies related to spring-boot-starter-web and ...
22
votes
5
answers
21k
views
How to perform an action only if the Mono is empty and throw an error if not empty
I'm trying to convert a project to use Spring WebFlux and am running into a problem getting some basic business logic working. I have a repository layer that is responsible for retrieving / ...
21
votes
4
answers
59k
views
WebFlux functional: How to detect an empty Flux and return 404?
I'm having the following simplified handler function (Spring WebFlux and the functional API using Kotlin). However, I need a hint how to detect an empty Flux and then use noContent() for 404, when the ...
21
votes
4
answers
36k
views
Spring Cloud Gateway; Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway Issue
I got this below error when run the API-GATEWAY, I tried so many ways but I couldn't solve this issue.
Description:
Spring MVC found on classpath, which is incompatible with Spring Cloud Gateway.
...
21
votes
2
answers
13k
views
How to collect paginated API responses using spring boot WebClient?
I have a paginated response from an URL, I want to keep on hitting the next page URL which I get from the previous response and keep on collecting items till I don't have a "nextPage" URL in my ...
20
votes
2
answers
14k
views
Error when using @EnableWebFluxSecurity in springboot
Currently I´m trying to integrate JWT Authentication in an existing Spring Boot Webflux Project.
As a template I used this medium article: https://medium.com/@ard333/authentication-and-authorization-...
20
votes
4
answers
44k
views
How to use Spring WebClient to make multiple calls simultaneously?
I want to execute 3 calls simultaneously and process the results once they're all done.
I know this can be achieved using AsyncRestTemplate as it is mentioned here How to use AsyncRestTemplate to ...
20
votes
2
answers
36k
views
HTTP Response Exception Handling in Spring 5 Reactive
I'm developing some reactive microservices using Spring Boot 2 and Spring 5 with WebFlux reactive starter.
I'm facing the following problem: I want to handle all HTTP Statuses that I receive from ...
20
votes
1
answer
10k
views
Using Virtual Threads (Project Loom) with Spring WebFlux/Reactor/Reactive libraries
Java Virtual Threads
In Java 19 were introduced Virtual Threads JEP-425 as a preview feature.
After some investigation of concept of Java Virtual Threads (Project Loom), called sometimes lightweight ...
19
votes
5
answers
10k
views
Creating custom ErrorWebExceptionHandler fails
I am trying to create my own ErrorWebExceptionHandler in Spring Boot 2 by extending the default one but my application fails to start with the following message:
Caused by: java.lang....
19
votes
4
answers
12k
views
How to use "Functional bean definition Kotlin DSL" with Spring Boot and Spring WebFlux?
At https://github.com/spring-projects/spring-framework/blob/master/spring-context/src/main/kotlin/org/springframework/context/support/BeanDefinitionDsl.kt the comment shows how to define Spring Beans ...
19
votes
2
answers
13k
views
Spring Security 5 Calling OAuth2 Secured API in Application Runner results in IllegalArgumentException
Given the following code, is it possible to call a Client Credentials secured API in an application runner?
@Bean
public ApplicationRunner test(
WebClient.Builder builder,
...
19
votes
3
answers
15k
views
Fire and forget with reactor
I have a method like below in my Spring boot app.
public Flux<Data> search(SearchRequest request) {
Flux<Data> result = searchService.search(request);//this returns Flux<Data>
...
18
votes
4
answers
12k
views
okhhtp3 mockserver java.lang.NoClassDefFoundError: okhttp3/internal/concurrent/TaskRunner$RealBackend
Maven dependency
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>mockwebserver</artifactId>
<version>4.9.0</version&...
18
votes
2
answers
16k
views
How to set event-loop pool size in Spring Webflux / WebClient?
In multi-reactor framework such as Vert.X we can set the number of event-loop threads, e.g.:
final VertxOptions vertxOptions = new VertxOptions();
vertxOptions.setEventLoopPoolSize(16);
final Vertx ...
17
votes
1
answer
16k
views
Spring WebFlux - ServerResponse Jackson Serializer problems
I have a problem during sending a HTTP GET request to my web server. Here is a snippet of code which is responsible for this resource:
@GetMapping("/events")
public Mono<ServerResponse> ...
17
votes
1
answer
33k
views
Spring Boot WebClient.Builder bean usage in traditional servlet multi threaded application
I would like to have a http client to call other microservice from Spring Boot not reactive application. Because of RestTemplate will be deprecated I tried to use WebClient.Builder and WebClient. ...
17
votes
1
answer
7k
views
Spring WebFlux WebClient resilience and performance
I just test by sample PoC project some blocking / non blocking solutions in simple common scenario.
Scenario:
There are rest blocking endpoint which is quite slow - each request tooks 200 ms.
There ...
17
votes
5
answers
42k
views
org.springframework.web.reactive.function.UnsupportedMediaTypeException: Content type 'text/xml;charset=UTF-8' not supported for bodyType
using Java 11, SpringBoot 2, WebFlux, WebClient and Jackson
trying to use Spring WebClient to consume a Web service endpoint that returns XML, content type: 'text/xml;charset=UTF-8'
Jackson XML ...
17
votes
2
answers
6k
views
Is there working example of OAuth2 with WebFlux
I'm trying to add OAuth2 to WebFlux and can't find any working example.
To Implement own Authorization Server I use such code:
@EnableAuthorizationServer
@Configuration
public class ServerAuth ...
16
votes
1
answer
15k
views
Spring Webflux vs Vert.x
We need to start working on a microservice with an initial plan to use Vert.x for the same. With the recent Milestone releases of Springboot 2.0 including the Reactive support, we are now also ...
16
votes
2
answers
32k
views
How to intercept a request when using SpringBoot WebClient
I am trying to use the WebClient to call my restServices. Previously on RestTemplate, we had ClientHttpRequestInterceptor defined and attached to the RestTemplate to intercept and modify the requests. ...
16
votes
6
answers
6k
views
How to send email reactive in spring web-flux
I'd like to stay complete reactive within my new spring application. Therefor I use web-flux/ reactor and ReactiveRepository with MongoDB.
Do you know how to integrate java-mail reactively into the ...