Spring Boot 2.0 disable default security

According to the new updates in Spring 2.0, if Spring Security is on the classpath, Spring Boot will add @EnableWebSecurity.So adding entries to the application.properties ain’t gonna work (i.e it is no longer customizable that way). For more information visit the official website Security changes in Spring Boot 2.0 Albeit not sure about your requirement … Read more

How to log request and response bodies in Spring WebFlux

This is more or less similar to the situation in Spring MVC. In Spring MVC, you can use a AbstractRequestLoggingFilter filter and ContentCachingRequestWrapper and/or ContentCachingResponseWrapper. Many tradeoffs here: if you’d like to access servlet request attributes, you need to actually read and parse the request body logging the request body means buffering the request body, … Read more

How to customize SpringWebFlux WebClient JSON deserialization?

Here’s an example that customizes the ObjectMapper for JSON (de)serialization. Note that for streaming purposes, different encoders/decoders are being used but the principle remains the same for their configuration. ExchangeStrategies strategies = ExchangeStrategies .builder() .codecs(clientDefaultCodecsConfigurer -> { clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonEncoder(new Jackson2JsonEncoder(new ObjectMapper(), MediaType.APPLICATION_JSON)); clientDefaultCodecsConfigurer.defaultCodecs().jackson2JsonDecoder(new Jackson2JsonDecoder(new ObjectMapper(), MediaType.APPLICATION_JSON)); }).build(); WebClient webClient = WebClient.builder().exchangeStrategies(strategies).build();

what does Mono.defer() do?

It is a bit of an oversimplification but conceptually Reactor sources are either lazy or eager. More advanced ones, like an HTTP request, are expected to be lazily evaluated. On the other side the most simple ones like Mono.just or Flux.fromIterable are eager. By that, I mean that calling Mono.just(System.currentTimeMillis()) will immediately invoke the currentTimeMillis() … Read more

Using spring HATEOAS with spring webflux Functional Web Framework (reactor-netty)

By definition, you’re creating a custom route and Spring HATEOAS is an opinionated set of frameworks meant so you don’t have to lift a finger. What you are trying to do, and what Spring HATEOAS is doing are contradictory. So, you will have to manually create the payload if you want embedded hyperlinks. Although, this … Read more

Spring MVC (async) vs Spring WebFlux

The Servlet async model introduces an async boundary between the container threads (1 Servlet request/thread model) and the processing of the request in your application. Processing can happen on a different thread or wait. In the end, you have to dispatch back to a container thread and read/write in a blocking way (InputStream and OutputStream … Read more

how to log Spring 5 WebClient call

You can easily do it using ExchangeFilterFunction Just add the custom logRequest filter when you create your WebClient using WebClient.Builder. Here is the example of such filter and how to add it to the WebClient. @Slf4j @Component public class MyClient { private final WebClient webClient; // Create WebClient instance using builder. // If you use … Read more

DataBufferLimitException: Exceeded limit on max bytes to buffer webflux error

This worked for me: Create a @Bean in one of your configuration classes or the main SpringBootApplication class: @Bean public WebClient webClient() { final int size = 16 * 1024 * 1024; final ExchangeStrategies strategies = ExchangeStrategies.builder() .codecs(codecs -> codecs.defaultCodecs().maxInMemorySize(size)) .build(); return WebClient.builder() .exchangeStrategies(strategies) .build(); } Next, go to your desired class where you want … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)