Getting Started With Spring Webflux

Most traditional applications deal with blocking calls or, in other words, synchronous calls. This means that if we want to access a particular resource in a system with most of the threads being busy, then the application would block the new one or wait until the previous threads complete processing its requests. If we want to process Big Data , however, we need to do this with immense speed and agility.

CVE report published for Spring Framework

We have released Spring Framework 5.3.17 to address the following CVE report. CVE-2022-22950: Spring Expression DoS Vulnerability Please review the information in the CVE report and upgrade immediately. Spring Boot users should upgrade to 2.5.11 or 2.6.5. CVE-2022-22950: Spring Expression DoS Vulnerability Severity Medium Vendor Spring by VMware Description In Spring Framework versions 5.3.0 - 5.3.16 and older unsupported versions, it is possible for a user to provide a specially crafted SpEL expression that may cause a denial of service condition.

Resilience and Best Patterns

Monolithic solutions or solutions where a single point of failure can derail an operation is a big problem. In products and platforms that target availability as an essential feature, this problem ends up creating major engineering challenges. This difficulty can be solved with a Microservices architecture. This architecture aims to: Make processes independent and managed in a unique way and without interdependence, so responsibilities are divided and decentralized, something very common in a distributed computing pattern.

Logging MongoDB Queries with Spring Boot

1. Overview When using Spring Data MongoDB, we may need to log to a higher level than the default one. Typically, we may need to see, for example, some additional information such as statement executions or query parameters. In this short tutorial, we’ll see how to modify the MongoDB logging level for queries. 2. Configure MongoDB Queries Logging MongoDB Support offers the MongoOperations interface or its primary MongoTemplate implementation to access data, so all we need is to configure a debug level for the MongoTemplate class.

Send multipart/form-data requests using Resttemplate

A multipart/form-data request can contain multiple sub-request bodies, each with its own separate header and body. Each sub-request body has its own separate header and body, and is typically used for file uploads. Here we use RestTemplate to send a multipart/form-data request. RestTemplate It’s really simple, it’s all in the code. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 package io.

Packaging SpringBoot applications with Docker

Previously, we used Docker to build services related to the development environment, and also to build dependency services in the development and testing environment, and then also used Nexus to build Docker’s self-service, so this time we came together to deploy SpringBoot applications with Docker. Step by step to all the Dockerization march. Build SpringBoot project The project is relatively simple, no data interaction, no complex business, just a print statement.

Spring Authorization Server 0 2 3 Available Now

⭐ New Features Apply default settings for public client type #656 Decompose OAuth2ClientAuthenticationProvider #655 Optimize InMemoryOAuth2AuthorizationService #654 Federated Identity sample #641 Use OAuth2TokenGenerator for OAuth2AuthorizationCode #639 Add OAuth2TokenGenerator implementation for OAuth2RefreshToken #638 Allow Token Introspection to be customized #630 Introduce OAuth2TokenGenerator #628 Add Assert.notNull() for AuthenticationProvider additions #530 Support opaque access tokens #500 Allow Token Introspection to be customized #493 Seperate JWT Token generation #414 Add a login with Google Authorization Server Sample #106 🐞 Bug Fixes Dynamic client registration should not generate client_secret for private_key_jwt #657 /.

Spring Boot 2.6.5 Available Now

⭐ New Features Add EIGHTEEN to JavaVersion enum #30132 🐞 Bug Fixes ConfigurationPropertyName#equals is not symmetric when adapt has removed trailing characters from an element #30392 Thymeleaf auto-configuration in a reactive application can fail due to duplicate templateEngine beans #30385 server.tomcat.keep-alive-timeout is not applied to HTTP/2 #30321 Setting spring.mustache.enabled to false has no effect #30256 bootWar is configured eagerly #30213 Actuator @ReadOperation on Flux cancels request after first element emitted #30161 Unnecessary allocations in Prometheus scraping endpoint #30125 No metrics are bound for R2DBC ConnectionPools that have been wrapped #30100 Condition evaluation report entry for a @ConditionalOnSingleCandidate that does not match due to multiple primary beans isn’t as clear as it could be #30098 Generated password are logged without an “unsuitable for production use” note #30070 Dependency management for Netty tcNative is incomplete leading to possible version conflicts #30038 Files in META-INF are not found when deploying a Gradle-built executable war to a servlet container #30036 Dependency management for Apache Kafka is incomplete #30031 spring-boot-configuration-processor fails compilation due to @DefaultValue with a long value and generates invalid metadata for byte and short properties with out-of-range default values #30022 📔 Documentation Add Apache Kafka to the description of the Messaging section #30389 Default value of spring.

Building Native Images with GraalVM and Spring Native on Apple's M1 Architecture

It finally happened! They did it! They did it just in time for me to get on the road and start building applications on the road with my shiny new laptop, too! JOY!! Oracle and the GraalVM team released GraalVM and the GraalVM native image capability for Apple M1! I’ve been waiting for this day for so, so, so long! I bought the first Apple M1 the day of the announcement way back in 2020 (does anybody remember that far back?

Notes on RabbitMQ with Spring Boot

Introduction Suppose our application organizes asynchronous domain logic inside DomainEventListener’s like the following code snippet. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 interface DomainEventListener { val topic: String fun handle(event: DomainEvent) } @Component class UserRegistered: DomainEventListener { override val topic = "user:registered" // How deserialization is performed is left out. override fun handle(event: DomainEvent) { // perform business logic } } This post shows how to integrate these listeners with Spring AMQP by taking advantage of Spring’s infrastructure.

Moving from Spring Cloud Netflix Zuul to Spring Cloud Gateway

I’ve been using Netflix Zuul for many years as a proxy for APIs. Some weeks ago I tried to bootstrap a new project and add the zuul starter via spring initializr and couldn’t find it anymore. After some research it seems that Spring Cloud has moved over to Cloud Gateway and discontinued Netflix Zuul. Maybe this was just a rebranding of the Spring team but tbh I don’t care and want to follow the Spring Cloud team with that.

Spring Security without the WebSecurityConfigurerAdapter

In Spring Security 5.7.0-M2 we deprecated the WebSecurityConfigurerAdapter , as we encourage users to move towards a component-based security configuration. To assist with the transition to this new style of configuration, we have compiled a list of common use-cases and the suggested alternatives going forward. In the examples below we follow best practice by using the Spring Security lambda DSL and the method HttpSecurity#authorizeHttpRequests to define our authorization rules. If you are new to the lambda DSL you can read about it in this blog post.

Spring Cloud Introduction to Service Discovery Netflix Eureka

Micro-services are all good until they come with their distributed challenges which normally we don’t face in monolithic based applications. Just like this one! Understanding the problem In order to fully get the main purpose of the solution let us first understand the underlying problem. As the diagram above shows, we have to micro-services communicating via a certain network: Micro-service I with the IP address 10.10.10.10 , and port 8080 Micro-service II with the IP address 20.

Messaging with RabbitMQ in Spring Boot Application

In this article, we will learn about RabbitMQ and explore its common use-cases. We will also walk through a step-by-step guide to implement messaging using RabbitMQ in a Spring Boot Application and will see how to publish and consume messages in a queue using RabbitMQ. So, let’s begin learning! What is a RabbitMQ? RabbitMQ is an open-source message broker that allows enterprise applications to communicate with each other. It’s a popular AMQP (Advanced Message Queuing Protocol)broker.

Load Balanced Websockets with Spring Cloud Gateway

The ability to have real-time two-way communication between the client and the server is a key feature in most modern web apps. A simple approach to setting up WebSockets in Spring Boot is covered in Simple WebSockets with Spring Boot, which uses an in-memory message broker. This approach falls short, though, when you scale up and add additional servers. Users connected to different servers would have no way of communicating or getting updates pushed to them for something that’s happened on another server.

Spring Cloud Config Server - Encryption and Decryption

While using Spring Cloud Config Server, we also have the feature to encrypt sensitive information that is otherwise stored as plain text in our external git repository. This prevents anyone who has read access to the external repository from accessing confidential information and is highly highly recommended if you are using a Spring Cloud Config Server. Note: If you haven’t set up Spring Cloud Config Server yet check out my other article on how to set up a spring cloud config server.

Spring Cloud Config Server: Step by Step

Spring Cloud Config Server is used to provide server-side and client-side support for externalized configuration in a distributed system. So when you have multiple microservices, and you want to easily control the configuration for all of them at one go - you’ll mostly be looking at Spring Cloud Config Server. So how do we do this? We will create a git project which contains all your properties files for the multiple microservices that you have (easy enough).

Spring Data JPA Query Method by Multiple Columns Example

In this tutorial, we will learn how to write a Spring Data JPA query method or finder method for multiple columns/fields. Consider the following Product entity class and if we want to retrieve products by their name OR description fields then here is the Spring data JPA query method: 1 public List<Product> findByNameOrDescription(String name, String description); Let’s create a complete example to understand end to end. Maven Dependencies Create a Spring boot project and add the following maven dependencies to it:

Spring Boot Integration Testing MySQL CRUD REST API Tutorial

In this tutorial, we will learn how to perform Integration testing Spring boot application using @SpringBootTest annotation. We use MySQL database to store and retrieve the data. Let’s first take a look at the overview of @SpringBootTest annotation. @SpringBootTest Annotation Spring Boot provides @SpringBootTest annotation for Integration testing. This annotation creates an application context and loads the full application context. @SpringBootTest will bootstrap the full application context, which means we can @Autowire any bean that’s picked up by component scanning into our test.

URL Rewriting With Spring Cloud Gateway

1. Introduction A common use case for the Spring Cloud Gateway is to act as a facade to one or more services, thus offering clients a simpler way to consume them. In this tutorial, we’ll show different ways to customize the exposed APIs by rewriting the URLs before sending the request to the backends. 2. Spring Cloud Gateway Quick Recap The Spring Cloud Gateway project is built on top of the popular Spring Boot 2 and Project Reactor, so it inherits its main treats: