Multipart File Upload Client Using Spring REST Template

In this example I am going to show you how to test file upload using Spring Boot Rest Template API. You can always use any REST based testing tools, such as, Postman, Talend, etc. but when you do not have any access to such REST based client tools, for example, your organization has blocked access to such REST client tools….

Additional Configurations In Spring Boot Application

Additional Config Here I am going to tell about additional config or configurations in your spring boot application. Now what could be the additional configurations in your spring boot application. Generally you define configurations into application.properties file under class path folder. But what if your application needs more configurations which could be supplied during runtime or the jar which is…

Spring JdbcTemplate – Select Specific Columns From Table

Specific Columns Selection Here I am going to show you an example how to select only specific columns from a table. So you only need to select few columns from a table instead of selecting all columns. In other words you are going to fetch those columns which are required for your business purpose.

Spring Boot Composite Primary Key Example

Composite Primary Key Composite primary key is a combination of two or more columns in a table. So instead of a single column to be a primary key, more than one column or field is made to be a primary key to uniquely identify the rows in a given table. Let’s say you have created a table called user in your database…

Spring Boot Cucumber Integration Using Gradle

Cucumber Cucumber is a BDD (behavior driven development) framework for running automated acceptance or integration test cases. Cucumber framework is written in Ruby language, but it is also available in other programming language. Cucumber uses Gherkin parser but the implementation is done using the target language. Cucumber allows the execution of feature documentation written in business-facing text. Cucumber works with…

How To Write Junit Test For Spring Boot Main Class

Introduction Here I am going to show you how to write Junit test for Spring Boot main class. A class having main method in Spring boot application is called main class and the purpose of this class is to deploy the application into embedded Tomcat server without configuring deployment descriptor or generating war file for the application. This way you…

Spring Boot Data JPA Entity DTO Mapping Using MapStruct

Introduction In this example I will show you how to convert entity class to DTO (Data Transfer Object) class and DTO class to entity class using MapStruct. So, MapStruct will map entity class to DTO class or vice versa. This example will test both from RESTful webservices and standalone main class. Spring Boot provides CommandLineRunner interface to run the project…

Spring Boot REST API MultiValueMap Example

MultiValueMap In this example I am going to show you how to use Spring’s MultiValueMap in REST API. This MultiValueMap is similar to the Jersey’s MultivaluedMap. A MultiValueMap<K, V> or MultivaluedMap<K, V> is a map of key-values pairs. Each key can have zero or more values, where K – the type of keys maintained by this map and V – the type of mapped values. This…

Spring Boot Filters Example

Introduction Servlet filters are Java classes that are invoked at pre and post processing of requests. So filters are used to intercept requests from clients before they access requests at backend (server). to manipulate responses from server before they are sent back to the client RequestContextFilter is also a servlet filter that extends OncePerRequestFilter that extends GenericFilterBean which implements servlet…

PreAuthorize HasPermission Security Using Spring Boot Data JPA

Introduction The ability of hasPermission() method in Spring Boot Security applications is to determine the accessibility of a particular user for the application. The permission of an access can be read, write, etc. So, a particular user has defined set of access permission by which a user can perform certain activities in the application. The most useful annotation @PreAuthorize, which…