Natural Programmer's Blog

Topics on Spring Framework for developing elegant real-world applications

Supporting Multi-Form Request Data In Spring RESTful Web Services

In this post, we'll discuss how to receive data in a REST end-point in multiple formats. Say you have an endpoint for adding customers, as below: POST /customers There could be two types of customers, INDIVIDUAL and ORGANIZATION. For individuals, the body would have the following format: { ...

READ MORE

Using Postman REST Client Cleverly - Some Quick Tips

Postman is one of the most popular API development environments, which needs no introduction to API developers. But strangely, numerous API developers often ignore many of its key features and make their work unnecessarily difficult. In this post, we'll discuss such key features that every API...

READ MORE

Spring Security 5 OAuth 2.0 Login and Signup in stateless RESTful Web Services

This post has moved to DZone.

READ MORE

How to get the current user in a Spring Security application

When developing an application, we sometimes need to access the currently logged in user programmatically. In this post, we’ll discuss how to do it when using Spring Security. When someone logs in, Spring Security creates an Authentication object, and stores that in the security context. The...

READ MORE

Spring Framework 5: What’s New For A Common Developer

Spring Framework 5 is coming – with many shiny features – including a new reactive framework. You can find the list of new features at many places in the Internet. Here is a good post on it. So, I gave a closer look to figure out what’s in it for my students. Most of the grand features doesn’t...

READ MORE

Writing Readable Code With Java 8 Method References

Java 8 lambda expressions make our code concise and readable. However, it’s the method references, along with the static and default methods in functional interfaces, which makes our code shine. Let’s take an example. Suppose we have an array of names that we want to sort. The array looks like...

READ MORE

Exception Handling in Spring Boot REST Web Services - a real-world pattern - part II

This article has moved to https://www.naturalprogrammer.com/courses/332639/lectures/5397747.

READ MORE

Exception Handling in Spring Boot REST Web Services - a real-world pattern - part I

This article has moved to https://www.naturalprogrammer.com/courses/332639/lectures/5397631

READ MORE

Removing null values from JSON responses in Spring Boot

We often return partially filled objects from our controller methods. For example, when returning the current user data, you’d not like the password and other sensitive fields to be returned. You may create a new user object, only fill the fields that you’d like returned, and then return that...

READ MORE

How to avoid double validation in Spring Boot applications

When developing an application, we sometimes reuse the entity classes as command objects. In other words, we use the same entity classes to receive user inputs. See this class for example: @Entity public class Employee { @Id private Long id; @Size(min=1, max=50) ...

READ MORE