Multi-layered applications often require to map between different object models (e.g. entities and DTOs). Writing such mapping code is a tedious and error-prone task. MapStruct aims at simplifying this work by automating it as much as possible. In this post, I will give you an overview of MapStruct and the steps needed to integrate it into your project.
Many Java applications have dependencies that aren’t available in a public or private Maven repository. Sometimes you may have just a third party java library, packaged as a jar, that you need to integrate in your application. This is very common when you have Oracle as your database and you need to connect to the db using the ojdbc.jar which is not available in maven central repository. You need to download it from Oracle website and then need to integrate it in the maven project as a third party dependency.
In this post, I will show how to add a third party client jar to a maven project.
In this post, I will demonstrate a simple java program, I recently faced, to encode a string to a specific requirement and later I will also show how to decode it back. Lets have a look at the requirement. You need to encode a string having the consecutive repetitive characters with the character itself followed […]
Yesterday, I had the task to call some rest endpoints for a backend application. The backend application was a spring boot application and so I used the spring RestTemplate to call the service endpoints. The endpoint was consists of several requests with type GET, POST, DELETE. Everything was running fine except one, when I tried to make a GET request that has request body.
This was a GET request, that used the body to transport data. GET requests should pass data in form of request parameters, query strings or header information. It does not make sense, to use the body for get requests. Springs RestTemplate did think the same and did not send the data along with in the request, because GET requests should have request parameters not body entities. I was not able to change the rest service backend, as I was just a consumer and needed to get this going. So I needed to modify RestTemplate behavior to support this.
In this post, I will show how to use RestTemplate to make a GET request that has a request body.
A prime number (or a prime) is a natural number greater than 1 that cannot be formed by multiplying two smaller natural numbers. A natural number greater than 1 that is not prime is called a composite number. For example, 5 is prime because the only ways of writing it as a product, 1 × 5 or 5 × 1, involve 5 itself. However, 6 is composite because it is the product of two numbers (2 × 3) that are both smaller than 6. The property of being prime is called primality. A simple method of checking the primality of a given number n, called trial division, tests whether n is a multiple of any integer between 2 and square root of n.
In this post, I will demonstrate how to check primality of a number and then generate a sequence of prime numbers using Java Stream API based on two different criteria.
The Fibonacci numbers are the numbers in an integer sequence, called the Fibonacci sequence, and characterized by the fact that every number after the first two is the sum of the two preceding ones. In this article I am going to show, how to generate fibonacci sequence using Java Stream API and later will discuss about the implementation.