Introduction In this example I am going to generate Van Eck sequence using Python programming language. Van Eck sequence is not used strictly for research purpose and it is actually application based professional activity. Van Eck sequence can be illustrated as follows: You start with a number 0 at the first position. Not necessarily you…

Posted in Python

Van Eck Sequence Using Python

Introduction Here I am going to show you how to insert line break in excel cell data using Apache POI in Java language. There may be requirements where you need to write long text in a cell or in multiple cells of excel file, but the long text is not fit within the view port…

Posted in Excel Java

Apache POI Insert Line Break In Excel Cell Data

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…

Posted in Spring Boot Spring JPA

Spring Boot Data JPA Entity DTO Mapping Using MapStruct

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

Posted in Spring Boot Spring REST

Spring Boot REST API MultiValueMap 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…

Posted in Spring Boot

Spring Boot Filters Example

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…

Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasPermission Security Using Spring Boot Data JPA

Introduction Here I am going to show you how to change context path of web application in Tomcat server. So, basically web applications are deployed into Tomcat server and meaningful, memorable context paths are assigned for web applications. Even if you do not want to set any context path for an application, you can do…

Posted in Server

Changing Context Path Of Web Application In Tomcat Server

Introduction In this example I am going to show you how to convert date from one format to another format in Java programming language. There are many situations where you need to convert date format in your Java based application from one format to another format. You can use prior to Java 8 and Java…

Posted in Java

Convert Date From One Format To Another Format In Java

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?):

Posted in Spring Boot Spring Security

Error bean securityConfig: unresolvable circular reference

Introduction Here I am going to show you how to create users in Tomcat server to manage applications, server status, etc. When you deploy application into Tomcat server, generally you put the war archive files under webapps folder of the Tomcat server. You can easily access the application once it is successfully deployed through its…

Posted in Server

How To Create Users In Tomcat Server

Introduction In this short example code I will show you how to create a new file for writing into it or if the file already exists then append to it instead of creating a new file using Java programming language. If you have a requirement that either you need to log some data into an…

Posted in File Java

Write Or Append To A File Using Java

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…

Posted in Spring Boot Spring JPA Spring Security

PreAuthorize HasRole Security Using Spring Boot Data JPA