External Configuration In Spring Boot Applications

External Configuration Spring Boot framework allows application developers to run the same Spring Boot application in different environments by making use of its feature of external configuration. The configuration in Spring Boot application uses environment variables, properties files, command-line arguments, YAML files, and system properties to mention the required configuration properties for its corresponding environments.

Google Organization Chart Using Spring

Organization Chart Here I am going to build google organization chart using spring boot framework. Organization chart can be used to display hierarchical data of an organization, for example, you can display the employees and their managers in hierarchical order. You can also find the organization hierarchy in your organization also. For example, you can see your manager, your manager’s…

Spring Boot Hikari Connection Pool Configurations

Hikari Connection Pool Here in this Spring Boot application example, I am going to show you how to use Hikari connection pool to use dedicated HikariDataSource instead of the use of database specific datasource. Hikari connection pool commonly known as HikariCP is extremely fast, light-weight, simple and production ready JDBC connection pool.

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 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…