Mock an Autowired Value Field in Spring with Junit 5

Mock @Value In this example I am going to show you how to mock an autowired field in Spring boot framework with Junit 5. When you use @Value annotation in Spring beans to read the value from properties file and later when you want to perform Junit test then you also need to pass value for this autowired field value…

Spring Data JPA @NamedQuery and @NamedQueries Example

Introduction Spring Data JPA provides multiple ways of selecting or fetching data from database server and one of the ways is using @NamedQuery or @NamedQueries. @NamedQuery and @NamedQueries can be created using XML configuration, external properties file or using Java based annotation config. Spring Data JPA supports both JPQL and SQL native named queries. Here I am going to show…

How to generate PDF report from MySQL database in Spring Boot

I am going to show yo how to download PDF file from MySQL database using Spring Boot and iText library in Java programming language. Many applications require dynamic generation of PDF documents for reporting purpose, such as, generating statements for customers, readers buying online specific chapters of a book, etc. In my another tutorial I had shown how to create…

How to generate Excel Report from MySQL Database in Spring Boot

Here I am going to show you how to download excel file from MySQL using Spring framework. Generating excel report from MySQL database has few advantages over other file formats. Most of the people you are working with in your organization are familiar with excel file format, hence it needs a short learning curve. You may also like to read…

How to Trace Microservices Logs with Spring Cloud Sleuth and Zipkin

Introduction Here I am going to explain how to trace Spring Boot Microservices logs with Spring Cloud Sleuth and Zipkin Server. Spring Cloud Sleuth provides Spring Boot auto-configuration for distributed tracing. One of the problems most developers face difficulty of tracing logs as your microservices applications grow and requests propagate from one microservice to another microservice. So it could be…

Create, Build, Package and Run Spring Boot Application with Docker

Build And Package With Docker Here in this tutorial I am going to show you how to create a simple Spring Boot application. Then how to build, package and run this Spring Boot application with Docker in Linux environment (CentOS). I am going to use both gradle and maven as build tools for running build on this Spring Boot application….

Top 10 best practices while building applications using Spring framework

Introduction In this tutorial I am going to discuss about best practices while building applications using Spring framework. Recently Spring has been one of the most popular Java based framework for building enterprise applications. Anyone can grasp the basic concepts and starts building applications using Spring right away but to become a strong developer you need to put efforts and…

Junit Testing for Multiple Files Upload Spring REST Controller

Introduction Here I am going to write Junit test case for testing multiple files upload in Spring REST Controller. I have already created how to upload multiple files using Spring REST API and I also had shown how to test it through REST client tool – Postman. In this tutorial I am going to use Junit 5, @WebMvcTest annotation to…

How include required gradle project into another project

Here I will tell you how to include the required gradle project into another project. Situation may occur when you need to have dependency of another gradle project into your current gradle project, but neither of these projects is a multi-module project. So in this case you can easily add the required project into your current working project. To include…

How To Upload Multiple Files Using Spring REST API

Multiple Files Upload Here in this tutorial I am going to show you how to upload multiple files using Spring Boot REST API. I had also shown you in my another example how to upload single file using Spring Boot REST API framework. For uploading file(s) you can use any client, for example, browser or any REST client (Postman) that…