Category: Spring Boot
Spring Boot
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…
Error bean securityConfig: unresolvable circular reference
Problem Recently while I was working with Spring Security in recent versions of Spring Boot framework (2.6.6/2.6.7), I was getting the following error (Requested bean is currently in creation: Is there an unresolvable circular reference?):
PreAuthorize HasRole Security Using Spring Boot Data JPA
Table of Contents Introduction Where is @PreAuthorize applicable? Prerequisites Project Setup MySQL Table Data Application Config Entity Classes Repository Interfaces Service Class REST Controller Class Security Config Spring Boot Main Class Testing Spring Security – PreAuthorize hasRole Source Code Introduction PreAuthorize hasRole Spring security will determine whether a user can invoke a method or not based on his/her role. hasRole()…